'With MobX + React, how can I initialize state without triggering a state update?
I have a settings store
class SettingsStore {
crosshairPosition
constructor() {
makeAutoObservable(this);
}
}
and an effect which save settings to the cloud when they are updated
useEffect(() => reaction(
() => settings.crosshairPosition,
() => cloud.save(settings.crosshairPosition)
), []);
Unfortunately the reaction triggers when I load the settings from the cloud on app startup, because the MobX store changes at that time. How should I restructure my application to avoid the state update on first load?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
