0

I am using redux So i have the user input their credentials and login after login I update the state but if the page refresh the data of state in lost which should not be done how can I make it non volatile the second thing I want some ui to not display If the user logged in i have google about it but the imports they are telling here are not working anymore

sarangkkl
  • 773
  • 3
  • 15
  • Does this answer your question? [Why does React/redux state reset on refresh?](https://stackoverflow.com/questions/62847854/why-does-react-redux-state-reset-on-refresh) – evolutionxbox Mar 21 '22 at 08:17
  • 1
    @sarangkkl the keyword you're looking for is "persist". You want to persist the redux store. There are options like localStorage (a feature of every modern browser) to do this. – timotgl Mar 21 '22 at 10:21
  • Does this answer your question? [How to persist redux state in the easiest way?](https://stackoverflow.com/questions/49330546/how-to-persist-redux-state-in-the-easiest-way) – timotgl Mar 21 '22 at 10:22

1 Answers1

1
Maybe u can wrap the content u don't want to render inside Curly Braces and do a 
check if you're Condition is true or false for example: 
{!isNotLoggedIn ? // content you want to show : return null }

It should only display the content when the User is Not Logged in, otherwise it returns nothing. And for the other Problem, i would try to save the State in the localStorage or Session Storage. Or otherwise send it to a server.

Yannick
  • 81
  • 2