สวัสดีทุกคน ฉันกำลังพยายามทำให้โค้ดของฉันอ่านง่ายและใช้งานได้จริงมากขึ้น
การใช้ redux-saga ใน React Native ฉันได้รับปัญหาบางอย่าง
เมื่อฉันพยายามโหลดแอป ฉันได้รับข้อผิดพลาด:
TypeError: store.getState ไม่ใช่ฟังก์ชัน
ข้อผิดพลาดนี้อยู่ที่:
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
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;
ฉันไม่รู้ว่าฉันทำอะไรผิด...