baseReducer is not a function. (In 'baseReducer(state, action)', 'baseReducer' is undefined)
See original GitHub issueI am getting this error when I try to setup redux-persist to work with my React Native app. “baseReducer is not a function. (In ‘baseReducer(state, action)’, ‘baseReducer’ is undefined)”
// configureStore.js
import { createStore, applyMiddleware, compose } from 'redux';
import { persistStore, persistReducer, autoRehydrate } from 'redux-persist';
import storage from 'redux-persist/lib/storage'; // defaults to localStorage for web and AsyncStorage for react-native
import thunkMiddleware from "redux-thunk";
import rootReducer from './'
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer);
const store = createStore(
persistedReducer,
{},
compose(
applyMiddleware(thunkMiddleware)
)
)
const persistor = persistStore(store)
export default { store, persistor }
//index.js
import { combineReducers } from "redux";
import stateReducer from "./appState";
import leadsReducer from "./leads";
import propertyReducer from "./property";
import userReducer from "./user";
import questionsReducer from "./questions";
import openHouseReducer from "./openHouse";
import pinReducer from "./pinReducer";
import houseImageReducer from "./houseImageReducer";
import searchReducer from "./search";
import switchReducer from './switchState';
import configureStore from './configureStore';
const rootReducer = combineReducers({
appState: stateReducer,
questions: questionsReducer,
property: propertyReducer,
search: searchReducer,
user: userReducer,
leads: leadsReducer,
openHouse: openHouseReducer,
pin: pinReducer,
houseImage: houseImageReducer,
switchState: switchReducer
});
export default rootReducer;
//App.js
import './ReactotronConfig';
import React, { Component } from "react";
import { Provider, connect } from "react-redux";
import { createStore, combineReducers, applyMiddleware } from "redux";
import Routes from './navigators/Routes'
import reducers from "./reducers";
import thunkMiddleware from "redux-thunk";
import { PersistGate } from 'redux-persist/integration/react';
import {store, persistor} from './reducers/configureStore';
// const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
// const store = Reactotron.createStore(rootReducer, compose(applyMiddleware(thunkMiddleware)))
class App extends Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Routes />
</PersistGate>
</Provider>
);
}
}
export default App;
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
React - TypeError: baseReducer is not a function
im making a SPA using React. I want the states persits after page refresh so i used 'redux-persist ...
Read more >React - TypeError: baseReducer is not a function-Reactjs
Coding example for the question React - TypeError: baseReducer is not a function-Reactjs.
Read more >react-help-baseReducer-error - CodeSandbox
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js. DashboardCtrl+Escape ...
Read more >TypeError: baseReducer is not a function. | by Natan | Medium
I'm having this error when npm start: TypeError: baseReducer is not a function. The app compiles but the page doesn't load.
Read more >https://unpkg.com/leoek-redux-persist@5.11.0-alpha...
... baseReducer: (State, Action) => State ): (State, Action) => State ... either rehydrate or register is not a function on the PERSIST...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
real problem was in configureStore.js had to export const store and export const persistor. instead of export default { store, persistor }
👍👍👍