Unverified Commit 14cb6556 authored by Ivan V's avatar Ivan V Committed by 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-
parent 397a375b
...@@ -12,6 +12,7 @@ export class Store { ...@@ -12,6 +12,7 @@ export class Store {
lastUpdate: observable, lastUpdate: observable,
light: observable, light: observable,
start: action, start: action,
hydrate: action,
timeString: computed, timeString: computed,
}) })
} }
......
...@@ -34,7 +34,7 @@ class Store { ...@@ -34,7 +34,7 @@ class Store {
stop = () => clearInterval(this.timer) stop = () => clearInterval(this.timer)
hydrate = (data) => { @action hydrate = (data) => {
if (!data) return if (!data) return
this.lastUpdate = data.lastUpdate !== null ? data.lastUpdate : Date.now() this.lastUpdate = data.lastUpdate !== null ? data.lastUpdate : Date.now()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment