Redux middleware logger
Basically from the redux.js.org middleware documentation, but with object diff.
store/store.js
import logger from '../logging/logger'
store = createStore(
  combineReducers({
      reducer,
      routing: routerReducer
  }),
  compose(applyMiddleware(...middleware))
)logging/logger.js
import { diff } from 'deep-object-diff';
const logger = store => next => action => {
    console.group(action.type)
    const oldState = store.getState()
    console.log('current state', oldState)
    console.info(`dispatching`, action)
    let result = next(action)
    const newState = store.getState()
    console.log('next state', newState)
    console.info('state diff', diff(oldState, newState))
    console.groupEnd()
    return result
}
export default loggerWritten by martinhj
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Redux 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#
 
 
 
