This repository was archived by the owner on Jun 4, 2024. It is now read-only.
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
"Too much recursion" error when hiding a Dash Table #877
Open
Description
When using a Dash Table which can be hidden, e.g. by changing the style or nesting inside of a dbc.Collapse
component, an initially hidden Dash Table with fill_width
set to True
will throw an indecipherable too much recursion
error.
Minimal example
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_table
import pandas as pd
app = dash.Dash()
server = app.server
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")
app.layout = html.Div(
[
html.Div(
children=[
dash_table.DataTable(
id="table",
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict("records"),
fill_width=False,
)
],
id="table-container",
style={"display": "none"},
),
html.Button(children="Show table", id="toggle", n_clicks=0),
]
)
@app.callback(
[Output("table-container", "style"), Output("toggle", "children")],
[Input("toggle", "n_clicks")],
)
def hide_table(n_clicks):
if n_clicks % 2 == 1:
return {"display": "none"}, "Show table"
return None, "Hide table"
if __name__ == "__main__":
app.run_server(debug=True, port=8050)