Redux问题 - store.getState不是函数。 (在'store.getState()'中,'store.getState'未定义)

时间:2017-08-10 20:25:03

标签: reactjs react-native redux react-redux persist

我一直在尝试将redux-persist集成到已经使用redux的项目中。

我按照基本用法示例,但收到错误store.getState is not a function.

以下是相关代码。

商店:

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)

项:

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 }
      }
    });
编辑:解决方案非常简单。只需确保您导出商店。感谢@markerikson

0 个答案:

没有答案