You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 26, 2018. It is now read-only.
If you call routerReducer() with no arguments to get back the initial state, it crashes with the following error:
reducer.js: Uncaught TypeError: Cannot read property 'type' of undefined
The generated code looks like this:
function routerReducer() {
var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0];
var _ref = arguments[1];
var type = _ref.type; // <==== _ref is undefined here and _ref.type causes the error
var payload = _ref.payload;
if (type === LOCATION_CHANGE) {
return _extends({}, state, { locationBeforeTransitions: payload });
}
return state;
}
This can be fixed in the original code by adding a default parameter for the action parameter:
It made me wonder though what the correct behavior of Babel should be here. Should it provide safe destructuring or still leave that up to your code? I checked Traceur though and it behaves the same way, so perhaps that's not part of the spec, but it seems dangerous.