Skip to content

Instantly share code, notes, and snippets.

@akashvaghela09
Created May 25, 2022 13:05
Show Gist options
  • Save akashvaghela09/b692bb6861b887a2c8f695920b5bb8b3 to your computer and use it in GitHub Desktop.
Save akashvaghela09/b692bb6861b887a2c8f695920b5bb8b3 to your computer and use it in GitHub Desktop.
Redux store
import { combineReducers, createStore, applyMiddleware, compose } from 'redux'
import { reducer as appReducer } from './app/reducer'
const rootReducer = combineReducers({
app: appReducer
})
const logger = (store) => (next) => (action) => {
// console.log("Dispatching Action Logger1", action, store.getState())
const value = next(action)
// console.log("Now State in Logger1", store.getState());
return value
}
const logger2 = (store) => (next) => (action) => {
// console.log("Dispatching Action Logger2", action, store.getState())
const value = next(action)
// console.log("Now State in Logger2", store.getState());
return value
}
const createComposer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(rootReducer,
createComposer( applyMiddleware(logger, logger2))
)
export {store}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment