Reputation: 13
I've been trying to integrate redux-persist into a project that already uses redux.
I followed the basic usage example, but I get the error store.getState is not a function.
Here's the relevant code.
Store:
import {createStore, combineReducers, applyMiddleware, compose} from "redux";
import {persistStore, autoRehydrate} from 'redux-persist'
import thunk from "redux-thunk";
import marketData from "./reducers/marketDataReducer";
import coin from "./reducers/coinReducer";
import account from "./reducers/accountReducer";
const store = createStore(
combineReducers({
marketData,
coin,
account
}),
compose(
applyMiddleware(thunk),
autoRehydrate()
),
);
persistStore(store)
Entry:
import { Navigation } from 'react-native-navigation';
import { registerScreens } from './navigation';
import Welcome from "./containers/welcome";
import store from "./store";
import { Provider } from 'react-redux';
registerScreens(store, Provider);
Navigation.startSingleScreenApp({
screen: {
screen: "welcome",
navigatorStyle: { navBarHidden: true }
}
});
EDIT: Solution was very simple. Just make sure you export your store. Thanks to @markerikson
Upvotes: 0
Views: 6573
Reputation: 67439
Doesn't look like you're actually exporting the store
variable from your store.js
file. Fix that first, and see if it works.
Upvotes: 4