Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable storage creation error for dynamic stores #1467

Open
Bram-Zijp opened this issue Feb 18, 2024 · 0 comments
Open

Option to disable storage creation error for dynamic stores #1467

Bram-Zijp opened this issue Feb 18, 2024 · 0 comments

Comments

@Bram-Zijp
Copy link

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 };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant