react-redux-setstate
Version:
A HOC that overrides the React setState API to use Redux for storing component state.
16 lines (13 loc) • 332 B
JavaScript
import { SET_STATE } from './actions'
export default function reducer(state = {}, action) {
if (
action.type === SET_STATE &&
(!state[action.payload.componentKey] || !action.payload.initializing)
) {
return {
...state,
[action.payload.componentKey]: action.payload.newState,
}
}
return state
}