I have a dash app which uses a dcc.Location
type pattern to populate a page content div. But if I add a callback that populates an element of the page content with an Input
that does not exist, the page never finished loading, and is stuck in ‘Updating…’. Here’s a minimal working example:
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash(__name__)
server = app.server
app.config["suppress_callback_exceptions"] = True
app.layout = html.Div(
[dcc.Location(id="url", refresh=False), html.Div(id="layout-div")]
)
@app.callback(
Output(component_id="layout-div", component_property="children"),
[Input(component_id="url", component_property="pathname")],
)
def update_layout_div(url):
return [html.Div(id="div-test")]
@app.callback(
Output(component_id="div-test", component_property="children"),
[Input(component_id="nonexistent-input", component_property="value")],
)
def example_callback(input):
return "never triggered"
if __name__ == "__main__":
app.run_server(debug=True)
Is it obvious why this doesn’t work? I feel that I’ve used this pattern before. I thought that the callback just shouldn’t be called until the nonexistent-input
input exists.