首页 文章

React Native TypeError store.getState不是函数

提问于
浏览
0

嗨,伙计们,我正在努力使我的代码更具可读性和实用性 .

在React Native中使用redux-saga我遇到了一些问题 .

当我尝试加载应用程序时,我收到错误:

TypeError:store.getState不是函数此错误位于:在Connect(Reprov)中(在App.js:17)
在RCTView(在View.js:44)
在提供者(在App.js:14)
在App中(在renderApplication.js:34)
在RCTView(在View.js:44)
在RCTView(在View.js:44)
在AppContainer中(在renderApplication.js:33)

src/store/configureStore.js


import {createStore, applyMiddleware} from 'redux'
import createSagaMiddleware from 'redux-saga';
import rootReducer from '../reducers';
import rootSaga from '../sagas';

export default function () {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    rootReducer,
    applyMiddleware(sagaMiddleware)
  );

  sagaMiddleware.run(rootSaga)

  return store;
}

src / App.js

import React, {Component} from 'react'
import { View } from 'react-native';
import { Provider } from 'react-redux';
import AppNavigation from './Navigation';
import store from './store/configureStore';
import Reproof from './screens/Reprov';
import Approval from './screens/Aprov';
import PushNotificationController from './components/Push';

class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <View style={{ flex: 1 }}>
          <AppNavigation />
          <Reproof />
          <Approval />
          <PushNotificationController />
        </View>
      </Provider>
    )
  }
}

export default App;

我不知道我做错了什么......

1 回答

  • 1

    您将存储作为变量导入,并且在文件中,它是一个函数:

    import store from './store/configureStore';

    试试这个 :

    import configureStore from './store/configureStore';
    

    然后创建一个变量存储

    const store = configureStore();
    

相关问题