我的减速机如:
const initialState = [
{
fname: null,
lname: false,
}
]
export default function login(state = initialState, action) {
switch (action.type) {
case LOGIN:
console.log("actions")
console.log(action)
console.log("reducers")
return
[{
fname: action.fname,
lname: action.lname,
}]
default:
return state
}
}
Run Code Online (Sandbox Code Playgroud)
在这里我得到行动的对象与fname和lname但这是给我错误说..Uncaught Error: Reducer "login" returned undefined handling "LOGIN". To ignore an action, you must explicitly return the previous state.
为什么我收到此错误?
更换:
return
[
Run Code Online (Sandbox Code Playgroud)
至:
return [
Run Code Online (Sandbox Code Playgroud)
因为首先是return;(js ;在行尾添加)
| 归档时间: |
|
| 查看次数: |
4310 次 |
| 最近记录: |