Vaibhav Malve Vaibhav Malve - 3 years ago 244
React JSX Question

redux-react-session how to get user info into state on refresh

I new to react. I am trying to do login for that i used redux-react-session package from npm to store sessions.

I am able to store session and autherise routes based on login.
But when i refresh page i want to restore user session into state.

As per document of redux-react-session we can user
sessionService.loadUser() method to get user back.

This function return promise in response.
But i am not able to get excat user object. Its returing user as a promise.

i have spend almost 10 hrs on it.

Can anyone help?

Answer Source

It is hard to understand what is going wrong with your code. Can you share it somehow? Are you sure you call this line of code after store creation?


And finally you can implement such logic by yourself. After login, put data to the localStorage. After store creation, get data from the localStorage and put it in your store. It is pretty easy logic.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download