【发布时间】:2021-07-19 18:26:19
【问题描述】:
我正在尝试使用 MobX 构建一个扫雷游戏,我遇到的问题是我不明白为什么我的棋盘上的单元格不会更新。
这是一个包含我的代码的沙盒
https://codesandbox.io/s/epic-sun-n1dnz?file=/src/Components/CellComponent.js
在我定义的“CellComponent”中:
<Button onClick={() => game.unveilCell(cell)}>{revealed? "2" : "?"}</Button>
所以我希望当我单击单元格时,它会显示数字 2,但只有当我等待它更新 1 分钟时,我假设我使用 MobX 观察者错误
【问题讨论】:
标签: reactjs mobx mobx-react