Skip to content

Instantly share code, notes, and snippets.

@Maluen
Created September 5, 2018 11:18
Show Gist options
  • Save Maluen/bbfb03f67e09f42249c7df404b27c3e5 to your computer and use it in GitHub Desktop.
Save Maluen/bbfb03f67e09f42249c7df404b27c3e5 to your computer and use it in GitHub Desktop.
Root reducer with ROOT_RESET action to reset the state back to its initial value
import { combineReducers } from 'redux';
import * as reducers from './index';
const appReducer = combineReducers({
...reducers,
});
const rootReducer = (state, action) => {
if (action.type === 'ROOT_RESET') {
state = undefined;
}
return appReducer(state, action);
};
export default rootReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment