Last active
November 8, 2019 00:15
-
-
Save cmilfont/d3f6366720648c039f71e70fd46355b9 to your computer and use it in GitHub Desktop.
Usando Redux sem combineReducer
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
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