Skip to content

Instantly share code, notes, and snippets.

@nomanHasan
Created November 24, 2017 19:48
Show Gist options
  • Select an option

  • Save nomanHasan/a886600df825d6a7d5be341b5971bec5 to your computer and use it in GitHub Desktop.

Select an option

Save nomanHasan/a886600df825d6a7d5be341b5971bec5 to your computer and use it in GitHub Desktop.
ConfigureStore
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