When I use dcc.Loading instead of html.Div dash throws the following exception:
An object was provided as
children
instead of a component, string, or number (or list of those). Check the children property that looks something like:…
EDIT: I observe the issue only when I choose an option from the dropdown menu and then clear selection by clicking on the x in the drop-down.
A minimal not-working is below:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_table
import pandas as pd
external_stylesheets = [
'https://codepen.io/chriddyp/pen/bWLwgP.css',
]
app = dash.Dash(__name__,
external_stylesheets=external_stylesheets,
suppress_callback_exceptions=False)
app.title='Explorer'
app.layout = html.Div([
html.Div([
dcc.Dropdown(id='dropdown-database',
options=[{'label': db, 'value': db} for db in ["Option1", "Option2"]]
),
]),
html.Div([
dcc.Loading([
html.Div([],id='display-area')
])
])
])
df_dummy=pd.DataFrame([{'sample_column':'sample_value'}])
dummy_table = dash_table.DataTable(
id='table',
columns=[{"name": i, "id": i} for i in df_dummy.columns],
data=df_dummy.to_dict('records'),
)
@app.callback(
Output('display-area', 'children'),
[Input('dropdown-database', 'value')]
)
def get_display_area(ddown_item):
if not ddown_item:
return [dummy_table]
#return html.Div("Select an option!")
else:
tables_list_content = (
html.Div(
[
html.P("Title"),
dummy_table
],
),
)
tabs = dcc.Tabs(
[
dcc.Tab(tables_list_content, label="Tables List"),
],
)
return [tabs]
app.run_server(debug=True)