简体   繁体   中英

How to save state after page refresh?

I have a button when I click on it with:

this.props.history.push("/dashboard");

I render another component, but at the same time my state is saved. But if I reload the page with f5, my state is lost and I can't load the correct data. Those. the state of the current component depends on another, how can I save this state upon reboot? localstorage does not quite fit

You have to use localStorage.

If you use Redux, It's best to do the following: use redux-persist

also you can see:

question: How do I store my state in localstorage in my Redux application?

you can see answer this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM