Reputation: 5863
I am making a react
app using redux
. I am going great except one issue.
Whenever I refresh the browser my state
changed to initial state. Lets say I have a user authenticated and I have set him as authenticated: true
and after authenticating when I refresh the page the state changed to initial and authenticated:false
is set.
I am confused why is this happening ?
Can anyone point what might be the issue here
Upvotes: 1
Views: 5378
Reputation: 153
Redux stores are not persistent. When the page reloads, all data is initialized again. If you would like to save a piece of your store (or the whole thing) you will need to save it in localstorage, or saving it to your server and making a REST request asking for the data again.
You can use this package to save your store into localstorage.
Upvotes: 7