Created
March 2, 2017 09:42
-
-
Save alfian0/8fc92c930990033e5c0da34da0fe3c6d to your computer and use it in GitHub Desktop.
[Redux] React Native - Create Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { | |
| AppRegistry, | |
| } from 'react-native'; | |
| import { Provider } from 'react-redux'; | |
| import { createStore, applyMiddleware, compose } from 'redux'; | |
| import thunkMiddleware from 'redux-thunk'; | |
| import createLogger from 'redux-logger'; | |
| import reducer from './app/reducers'; | |
| import AppContainer from './app/containers/AppContainer'; | |
| import callAPIMiddleware from './app/lib/callAPIMiddleware'; | |
| const loggerMiddleware = createLogger({ predicate: (getState, action) => __DEV__ }); | |
| function configureStore(initialState) { | |
| const enhancer = compose( | |
| applyMiddleware( | |
| thunkMiddleware, | |
| loggerMiddleware, | |
| callAPIMiddleware | |
| ), | |
| ); | |
| return createStore(reducer, initialState, enhancer); | |
| } | |
| const store = configureStore({}); | |
| const App = () => ( | |
| <Provider store={store}> | |
| <AppContainer /> | |
| </Provider> | |
| ); | |
| AppRegistry.registerComponent('MyApp', () => App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment