combineReducers VS Uncaught Error: Reducer "" returned undefined during initialization

In using combineReducers scene, pay attention reducers in the state initialization process, otherwise the process to combineReducers function will throw an exception because internal combineReducers were each reducer assertion.

Tracking the source known works as follows:

Continue to debug, enter assertReducerShape

Seen, here, processing for each assert rducer: incoming 'undefined' state and the outside actionType buisniess type, so that each reducer default branch go function, returns the final value, the value is undefined if it is considered your reducer assertion failure, non-security.

Thus, in the case where the combinedReducer, pay attention to the initial value of the processing of the reducer:

 

This is the end.

 

Guess you like

Origin www.cnblogs.com/surfer/p/11231896.html