I’m not posting a MWE because it is too complicated to extract it from the original app for now, but the following example should be enough to understand the issue.
I have 3 different callbacks targeting the same Output
components, so I use allow_duplicate
and prevent_initial_call
# First Callback
@callback(
[Output("locations", "options"),
Output("locations", "value"),
.....],
Input("search-button", "n_clicks"),
)
def get_closest_address(n_clicks):
logging.info("Called get_closest_address")
# Second callback
@callback(
[Output("map-scatter-layer", "children", allow_duplicate=True),
Output("locations", "options", allow_duplicate=True),
Output("locations", "value", allow_duplicate=True),
....],
Input("map", "clickData"),
prevent_initial_call=True
)
def map_click(clickData):
logging.info("Called map_click")
# Third callback
@callback(
[Output("locations", "options", allow_duplicate=True),
Output("locations", "value", allow_duplicate=True), ...],
Input("geolocation", "local_date"),
prevent_initial_call=True
)
def update_location_with_geolocate(_):
logging.info("Called update_location_with_geolocate")
I get the error : ReferenceError: A nonexistent object was used in an Output
of a Dash callback. The id of this object is locations
and the property is options@65301cc199c777e9a149e81bbce741f2
. The application seems to work just fine, though.
If I comment the third callback (update_location_with_geolocate
function) I don’t get any error. The logging
calls show that neither map_click
nor update_location_with_geolocate
are called when the application is loaded (as expected).
I’m trying to wrap my head around why, when update_location_with_geolocate
is defined then there is no locations
component defined in the layout, but there is when map_click
is defined.