short answer: use dcc.Store
longer answer: hidden divs was a workaround before we created dcc.Store
. They require adding the data to the DOM (which has some overhead even if the div is not displayed), and they can only store data that’s valid as the children
prop - in principle, just strings or arrays of strings. dcc.Store
has no DOM overhead, can store arbitrary JSON, and can also use localStorage
or sessionStorage
to persist across redraws.