redux-persist
redux-persist copied to clipboard
Option to disable storage creation error for dynamic stores
My store is created with or without redux-persist dynamically. It would be nice to disable storage creation errors when a store is initialized without using the redux-persist persistedReducer
and/or preferably when persistStore(store)
is not called.
Example:
import storage from "redux-persist/lib/storage";
import {
persistStore,
persistReducer,
} from "redux-persist";
const persistedReducer = persistReducer(
{
key: "root",
version: 1,
storage,
// ignore error option here?
},
rootReducer
);
export const createStore = (
persistToLocalStorage: boolean = false,
) => {
const store = configureStore({
reducer: persistToLocalStorage
? persistedReducer
: rootReducer,
});
// only error here when persistStore?
const persistor = persistToLocalStorage ? persistStore(store) : undefined;
return { store, persistor };
};