问题如下。稍后的实现将为引发错误
任何
它不知道的类型的操作。
创建存储时,redux调度
@@redux/INIT<SomeRandomString>
获取初始状态的操作。但您的reducer将抛出失败的整个引导过程。因此,您的应用程序根本无法启动。
switch (action.type){
case 'SET_TOKEN':
state = { ...state, token : action.payload }
break
case 'SET_USERNAME':
state = { ...state, username : action.payload }
break
default: // this will throw for redux init action as well.
throw new Error("Errore, nessuna azione corrispondente")
break
}
检查此项
comment
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
Esp注意
对于任何未知操作,必须返回当前状态。
和
如果当前状态未定义,则必须返回初始状态。