Hai teman-teman, saya mencoba membuat kode saya lebih mudah dibaca dan pragmatis.
Menggunakan redux-saga di React Native Saya mendapatkan beberapa masalah.
Ketika saya mencoba memuat aplikasi saya mendapatkan kesalahan:
TypeError: store.getState bukan fungsi
Kesalahan ini terletak di:
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;
Saya tidak tahu apa yang saya lakukan salah...