mobx中observable数据更新,响应式组件未更新
先上代码,说明问题:
store:
@observable toDoLists = []
@computed get toDos() {
const [ALL, DONE, UNDONE] = this.filterTypes;
switch (this.filterType) {
case DONE:
return this.toDoLists.filter(item => !!item.done)
case UNDONE:
return this.toDoLists.filter(item => !item.done)
case ALL:
default:
return this.toDoLists;
}
}
@action.bound addToDo(text) {
this.toDoLists.unshift({
text,
id: Date.now(),
done: false
})
console.log('todo list', this.toDos, this.toDoLists)
}
响应式组件:
@observer
class ToDolist extends Component {
render() {
const { toDos, handleChange } = this.props.store;
return (
<ul className={list_ul}>
{