Created
April 27, 2018 05:29
-
-
Save agoldis/c2ad4fc45d8ef0746fce994fb4f3a0bf to your computer and use it in GitHub Desktop.
Redux - deriveState store enhancer
This file contains hidden or 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
const deriveState = state => { | |
state.foo = "bar"; | |
return state; | |
} | |
const enhanceStore = createStore => (reducer, preloadedState, enhancer) => { | |
const store = createStore(reducer, preloadedState, enhancer); | |
const _originalGetState = store.getState; | |
store.getState = () => deriveState(_originalGetState()); | |
return store; | |
}; | |
export const store = createStore( | |
reducer, | |
initialState, | |
enhanceStore | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment