React项目报错:The slice reducer for key “xxx“ returned undefined during initialization.

React项目报错:The slice reducer for key “xxx“ returned undefined during initialization.,第1张


在react项目中报错:

 error:The slice reducer for key "recommend" 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中没有设置default

解决方法:给switch添加default

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1296659.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存