Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active November 8, 2019 00:15
Show Gist options
  • Save cmilfont/d3f6366720648c039f71e70fd46355b9 to your computer and use it in GitHub Desktop.
Save cmilfont/d3f6366720648c039f71e70fd46355b9 to your computer and use it in GitHub Desktop.
Usando Redux sem combineReducer
import { LOCATION_CHANGE } from 'connected-react-router';
import { connectRouter } from 'connected-react-router';
export default history => {
const handleRouter = connectRouter(history);
const initialState = {
router: connectRouter(history)
};
return (state = initialState, action) => {
if (action.type === LOCATION_CHANGE) {
return {
...state,
router: handleRouter(action.payload),
}
}
if (action.meta && action.meta.reducer) {
return action.meta.reducer(state, action);
}
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment