Created
November 24, 2017 19:48
-
-
Save nomanHasan/a886600df825d6a7d5be341b5971bec5 to your computer and use it in GitHub Desktop.
ConfigureStore
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 { createStore, applyMiddleware } from 'redux' | |
| //Redux Thunk need to be added as a middleware | |
| import thunkMiddleware from 'redux-thunk' | |
| // Redux logging middleware | |
| import { createLogger } from 'redux-logger' | |
| // Import the root reducer | |
| import rootReducer from '../reducers/rootReducer' | |
| // Create the redux logging middleware | |
| const loggerMiddleware = createLogger() | |
| // Configuring the Store. PreloadState is the initial State. | |
| export function configureStore(preloadedState) { | |
| return createStore( | |
| rootReducer, | |
| preloadedState, | |
| //Apply the middleware usign the Redux's provided applymiddleware function | |
| applyMiddleware( | |
| thunkMiddleware, | |
| loggerMiddleware | |
| ) | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment