-
Notifications
You must be signed in to change notification settings - Fork 17
Description
In the app/src/state/index.js file Add the following code:
import { createStore, compose, applyMiddleware } from 'redux'; import { fromJS } from 'immutable'; import createSagaMiddleware from 'redux-saga'; import devTools from 'remote-redux-devtools'; import Parse from 'parse/react-native'; import { AsyncStorage } from 'react-native'; import { persistStore, autoRehydrate } from 'redux-persist-immutable'; import createReducer from './reducers'; import sagas from '../sagas'; import Settings from '../settings'; const settings = Settings.load(); Parse.initialize(settings.parseServerApplicationId); Parse.serverURL = settings.parseServerURL; const sagaMiddleware = createSagaMiddleware(); function configureStore(initialState = fromJS({})) { const enhancers = [ autoRehydrate(), applyMiddleware(sagaMiddleware), ]; if (__DEV__) { enhancers.push(devTools()); } const store = createStore(createReducer(), initialState, compose(...enhancers)); sagas.forEach(saga => sagaMiddleware.run(saga)); persistStore(store, { storage: AsyncStorage }); return store; } module.exports = configureStore;