Doubt about the Redux-React store

Asked

Viewed 31 times

1

I have three rooms:

import { combineReducers } from 'redux';
import formularios from './formReducer';
import userLogin from './userReducer';
import errorReducer from './errorReducer';

export default combineReducers({
    formReducer: formularios,
    userReducer: userLogin,
    errorReducer: errorReducer
});

Problem

They work properly, but if I refresh the page, it returns the state of the store to the initial state, so I lose the user data, would it work anyway? As I would save the data of the logged-in user, I managed with localStorage and sessionStorage, but it would be the best practice?

Obs: It’s my first time here, if any information is missing, please inform me, I’m learning to use the tool.

  • 2

    Yes, that is the expected behavior. As for "how to store", it depends on the case. It may be local Storage, and there are also packages you can use like the Redux-persist or Redux-Storage. I recommend taking a look to see if it makes sense in your case

  • Thanks @Rafaeltavares, I read about the Redux-persist, will meet my need, simple and objective answer, thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.