Skip to content

Instantly share code, notes, and snippets.

@braska
Last active March 24, 2017 13:52
Show Gist options
  • Save braska/b0f598d50eebacb00ff9d9e49c50ec45 to your computer and use it in GitHub Desktop.
Save braska/b0f598d50eebacb00ff9d9e49c50ec45 to your computer and use it in GitHub Desktop.
Redux Dispatch Monkey Patching
/**
How to use:
1. Inside React Dev Tools select <Provider>
2. Copy this script
3. Paste to console
4. Run
*/
let store = $r.store;
let rawDispatch = store.dispatch;
$r.store.dispatch = (action) => {
console.group(action.type);
console.log('%c prev state', 'color: gray', store.getState());
console.log('%c action', 'color:blue', action);
const returnValue = rawDispatch(action);
console.log('%c next state', 'color: green', store.getState());
console.groupEnd(action.type);
return returnValue;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment