I’m finding unexpected behaviour when working with dcc.Location search and hash props.
If you set a callback with any of those as Inputs, they fire callback twice every time you load or reload the app. In the first run they have None
value and in second run they get their actual value.
Also, these callbacks get fired not only when those parts of the URI have been modified (namely, only the query string part or the hash part), but they are triggered every single time that the address url is modified, even if that part wasn’t modified.
To illustrate this, try this example in your local machine and see the logs from Dash when you modify parts of the url.
I’ve seen something related here: callbacks watching dcc.Location's url.pathname fire twice on first page load · Issue #138 · plotly/dash-core-components · GitHub, but my issue is that they trigger twice every time that path changes, not only on first page load and also that the callbacks regarding hash and search get fired even when those parts have not been affected.
It’s been a while since you wrote this, but I see the same.
In my case it is a real problem as I need to generate callbacks dynamically. This is possible, but since there may only be one callback per output, as dcc.Location triggers twice, the second creation stops the execution of the site code.