未验证 提交 14cb6556 编写于 作者: I Ivan V 提交者: GitHub

example fix: hydrate method of the mobx store needs to be an action (#19522)

By default, MobX 6 and later require that you use `actions` to make changes to the state, otherwise, it issues a warning in the console, because the `hydrate` method of the `store.js` class hasn't been declared an action, you can see this warning if you try to load pages that use hydration (ssg, ssr).
This pull request fixes that.

More info about the behavior:
https://mobx.js.org/actions.html#disabling-mandatory-actions-
上级 397a375b
......@@ -12,6 +12,7 @@ export class Store {
lastUpdate: observable,
light: observable,
start: action,
hydrate: action,
timeString: computed,
})
}
......
......@@ -34,7 +34,7 @@ class Store {
stop = () => clearInterval(this.timer)
hydrate = (data) => {
@action hydrate = (data) => {
if (!data) return
this.lastUpdate = data.lastUpdate !== null ? data.lastUpdate : Date.now()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册