gags gags - 9 months ago 48
React JSX Question

How to retain information for the logged in user on page reload or different tabs in browser

I have only started with react and redux and designed the login -sign up page.

Have an action that calls login-sign up API and a corresponding reducer.

I display some of this information on page and use it on some others. Now, I would like this state to be maintained when the browser is reloaded. How do I do it?

I have this header component binding this action that logs the user in.

Answer Source

Usually, you either store the state in localStorage, e.g. by using redux-persist or fetch the initial state from your server.