I have a webapp and already people using my application. I use redux-thunk to save the state in localStorage.
When I want to add a new field to my redux initial state, this is not automatically added to their store (because I use Redux-Thunk to save the state, and the new field does not exist on the saved state).
I only see the solution to reinitialise the redux state to add the new field. I could do this, but that would mean people are logged out to their application, which is not user friendly.
So my question: How can I add a field to the initalState, and add it automatically to the saved redux-thunk state?
I am using react-redux, redux-toolkit and redux-thunk
My code:
const reducers = combineReducers({
user: authReducer,
groups: groupReducer,
});
const persistConfig = {
key: "root",
storage,
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
const store = configureStore({
reducer: persistedReducer,
devTools: process.env.NODE_ENV !== "production",
middleware: [thunk],
});