Last active
March 24, 2017 13:52
-
-
Save braska/b0f598d50eebacb00ff9d9e49c50ec45 to your computer and use it in GitHub Desktop.
Redux Dispatch Monkey Patching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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