Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { createReactNavigationReduxMiddleware, createNavigationReducer, reduxifyNavigator } from 'react-navigation-redux-helpers';
import { connect } from 'react-redux';
// Middlewares
import createSagaMiddleware from 'redux-saga';
// Saga's
import user from './reducers/sagas/user'
import schedule from './reducers/sagas/schedule'
import evaluations from './reducers/sagas/evaluations'
import * as reducers from './reducers';
export default navigator => {
const navReducer = createNavigationReducer(navigator)
const reducer = combineReducers({
nav: navReducer,
...reducers
})
const sagaMiddleware = createSagaMiddleware()
const navMiddleware = createReactNavigationReduxMiddleware(
"root",
state => state.nav
);
const store = createStore(
reducer,
compose(
applyMiddleware(navMiddleware),
applyMiddleware(sagaMiddleware)
)
)
const App = reduxifyNavigator(navigator, "root")
const mapStateToProps = state => ({ state: state.nav })
const AppWithNavigationState = connect(mapStateToProps)(App)
// Run Saga's
sagaMiddleware.run(user)
sagaMiddleware.run(schedule)
sagaMiddleware.run(evaluations)
return { store, AppWithNavigationState }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.