35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
exports.__esModule = true;
|
||
|
|
|
||
|
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||
|
|
|
||
|
|
exports.routerReducer = routerReducer;
|
||
|
|
/**
|
||
|
|
* This action type will be dispatched when your history
|
||
|
|
* receives a location change.
|
||
|
|
*/
|
||
|
|
var LOCATION_CHANGE = exports.LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
|
||
|
|
|
||
|
|
var initialState = {
|
||
|
|
location: null
|
||
|
|
|
||
|
|
/**
|
||
|
|
* This reducer will update the state with the most recent location history
|
||
|
|
* has transitioned to. This may not be in sync with the router, particularly
|
||
|
|
* if you have asynchronously-loaded routes, so reading from and relying on
|
||
|
|
* this state is discouraged.
|
||
|
|
*/
|
||
|
|
};function routerReducer() {
|
||
|
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||
|
|
|
||
|
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||
|
|
type = _ref.type,
|
||
|
|
payload = _ref.payload;
|
||
|
|
|
||
|
|
if (type === LOCATION_CHANGE) {
|
||
|
|
return _extends({}, state, { location: payload });
|
||
|
|
}
|
||
|
|
|
||
|
|
return state;
|
||
|
|
}
|