[英]React Native TypeError store.getState is not a function
Hi guys I'm trying to make my code more readable and pragmmatic. 大家好,我正在尝试使我的代码更具可读性和实用性。
Using redux-saga in React Native I'm getting some issues. 在React Native中使用redux-saga我遇到了一些问题。
When I try to load the app I get the error: 当我尝试加载应用程序时,出现错误:
TypeError: store.getState is not a function
TypeError:store.getState不是函数
This error is located at:
该错误位于:
in Connect(Reprov) (at App.js:17) in RCTView (at View.js:44) in Provider (at App.js:14) in App (at renderApplication.js:34) in RCTView (at View.js:44) in RCTView (at View.js:44) in AppContainer (at renderApplication.js:33)
src/store/configureStore.js 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;
}
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;
I don't know what I'm doing wrong... 我不知道我在做什么错...
You are importing the store as a variable and in the file,it is a function : 您正在将商店作为变量导入,并且在文件中,它是一个函数:
import store from './store/configureStore';
try this : 尝试这个 :
import configureStore from './store/configureStore';
then create a variable store 然后创建一个变量存储
const store = configureStore();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.