首页 > 其他分享> > × Error: The slice reducer for key “auth“ returned undefined during initialization. If the state pas
× Error: The slice reducer for key “auth“ returned undefined during initialization. If the state pas
作者:互联网
Error: The slice reducer for key “auth” 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.
原因: switch (action.type) 没有设置default
export default function authReducer(state, action) {
switch (action.type) {
case SIGNUP:
return {
...state,
signup: {
loaded: false,
success: false,
}
}
default:
return state;
}
}
标签:slice,return,undefined,default,initialization,reducer,state,action,returned 来源: https://blog.csdn.net/xiaoxia188/article/details/118436086