MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / assertReducerShape

Function assertReducerShape

code/redux/public/app.js:21276–21290  ·  view source on GitHub ↗
(reducers)

Source from the content-addressed store, hash-verified

21274}
21275
21276function assertReducerShape(reducers) {
21277 Object.keys(reducers).forEach(function (key) {
21278 var reducer = reducers[key];
21279 var initialState = reducer(undefined, { type: _createStore.ActionTypes.INIT });
21280
21281 if (typeof initialState === 'undefined') {
21282 throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
21283 }
21284
21285 var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
21286 if (typeof reducer(undefined, { type: type }) === 'undefined') {
21287 throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + _createStore.ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
21288 }
21289 });
21290}
21291
21292/**
21293 * Turns an object whose values are different reducer functions, into a single

Callers 1

combineReducersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected