App not resetting with page refresh

One of the key principles of Dash is that variables should not be mutated out of the scope of callbacks. In this case you’re mutating app.layout['cities-checklist'].options inside the callback - this “isn’t allowed”.

Mutable state in the python session is dangerous because one user’s session can end up modifying the next user’s session. Also, when apps are deployed, their environment contains multiple processes (e.g. with gunicorn) and the mutations from one python session won’t persist or carry across to the next python session.

@alex_01 What effect are you trying to have here? If you want to have similar logic but have the app “reset” on page reload, then you can do something really similar by making a copy of the options instead of mutating them. That is:

import copy

....

def update_list(value):
    options = copy.copy(app.layout['cities-checklist'].options)
    ...
1 Like