我有这家商店:
const initialActors = {
list: 'Actor\'s lists',
actors: [
{
name: 'Angelina Jole',
involved: true
},
{
name: 'Bratt Pitt',
involved: false
},
]
}
我有一个简化器可以在我的商店中添加一个新演员:
const actors = (state = initialActors, action) => {
switch(action.type){
case 'ADD_NEW':
return {
...state.list,
actors: [
...state.actors,
action.name,
action.involved
]
}
default:
return state
}
}
我也有动作创作者,但这并不重要。我调度并显示我的状态:
store.dispatch(addNew({name: "Hello", involved: true}) ); // I have this action creator
console.log(store.getState()
console.log
显示非常困难的对象,其字母类似于:{0: "A", 1: "c"}
。怎么了?