sdgfsdh sdgfsdh - 10 months ago 56
React JSX Question

How should I log every dispatch call to a Redux store?

I want to debug my Redux application by logging every action sent to the dispatcher in my the console.

What is generally regarded as the best approach for doing this?


You can use a simple logging middleware, like the example in the redux middleware docs:

const logger = store => next => action => {'dispatching', action)
  let result = next(action)
  console.log('next state', store.getState())
  return result

Or use the redux-logger module, which basically does the same thing.