diff --git a/src/ConnectedRouter.js b/src/ConnectedRouter.js index 401925bd..6f115b15 100644 --- a/src/ConnectedRouter.js +++ b/src/ConnectedRouter.js @@ -59,10 +59,10 @@ const createConnectedRouter = (structure) => { } }) - const handleLocationChange = (location, action, isFirstRendering = false) => { + const handleLocationChange = ({location, action}, isFirstRendering = false) => { // Dispatch onLocationChanged except when we're in time travelling if (!this.inTimeTravelling) { - onLocationChanged(location, action, isFirstRendering) + onLocationChanged({location, action}, isFirstRendering) } else { this.inTimeTravelling = false } @@ -75,7 +75,7 @@ const createConnectedRouter = (structure) => { // Dispatch a location change action for the initial location. // This makes it backward-compatible with react-router-redux. // But, we add `isFirstRendering` to `true` to prevent double-rendering. - handleLocationChange(history.location, history.action, true) + handleLocationChange({location, action} = history, true) } } @@ -123,7 +123,7 @@ const createConnectedRouter = (structure) => { } const mapDispatchToProps = dispatch => ({ - onLocationChanged: (location, action, isFirstRendering) => dispatch(onLocationChanged(location, action, isFirstRendering)) + onLocationChanged: ({location, action}, isFirstRendering) => dispatch(onLocationChanged({location, action}, isFirstRendering)) }) const ConnectedRouterWithContext = props => { diff --git a/src/actions.js b/src/actions.js index 2f88cf01..ed45380c 100644 --- a/src/actions.js +++ b/src/actions.js @@ -4,7 +4,7 @@ */ export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE' -export const onLocationChanged = (location, action, isFirstRendering = false) => ({ +export const onLocationChanged = ({location, action}, isFirstRendering = false) => ({ type: LOCATION_CHANGE, payload: { location,