Use Local Storage Data from Partials


Any advice on how to use local storage data from partials?

I tried to create conditional hide/show elements inside layout page that remain unchanged after page reload or move to another page. I put the local storage variable inside partials, and add partials inside the layout. Using dynamic events on the button to change local state value.

However, it is not working, tried to add another local storage inside layout, and apply the same method and it works.

I would like to understand, what best practice to use local storage for this situation?

Found it, need to add local storage with same id on the layout page.
I don’t know if it the correct way to do it.