Skip to content
Advertisement

How i can save the toggle state and don’t lose after refresh the page

hello my project is done mostly from react and redux, i am buliding app in this app there is toggle when is on its sync the data to the calendar, and i want it to stay it toggle even after refresh the page. here is some code

JavaScript

and here after return

JavaScript

is there away to save the state taggle other than this.state ?

Advertisement

Answer

Save the state in localStorage on unmount and repopulate on initial mount

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement