想知道我的代码出了什么问题,当我尝试使用 redux 分派操作时,它给出了错误,这是我的 reducer.js 代码
import {UPDATE_LOGIN} from './constants'
const initialState = {
isLogged:false
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case UPDATE_LOGIN:
return [
...state,
{
isLogged:action.isLogged
}
];
default:
return state;
}
}
export default reducer;
Run Code Online (Sandbox Code Playgroud)
it gives a Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method.