Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug error in MobX strict-mode #14

Merged
merged 2 commits into from
Feb 22, 2020
Merged

Conversation

nighca
Copy link
Collaborator

@nighca nighca commented Feb 22, 2020

In #13 we replaced options.delay of MobX reaction with our own debounce realization, which caused that the effect will be run outside the effect handler of MobX reaction. So we need to wrap the effect with runInAction, or we got error in projects with strict-mode enabled:

mobx.module.js?daf9:92 Uncaught Error: [mobx] Since strict-mode is enabled, changing observed observable values outside actions is not allowed. Please wrap the code in an `action` if this change is intended. Tried to modify: FieldState@183._validateStatus
    at invariant (mobx.module.js?daf9:92)
    at fail (mobx.module.js?daf9:87)
    at checkIfStateModificationsAreAllowed (mobx.module.js?daf9:746)
    at ObservableValue.prepareNewValue (mobx.module.js?daf9:1057)
    at ObservableObjectAdministration.write (mobx.module.js?daf9:4045)
    at FieldState.set [as _validateStatus] (mobx.module.js?daf9:4209)

In addition, we enabled strict-mode before our test cases, so that we can find such error when running unit test next time.

@nighca nighca changed the title debug error in mobx strict-mode Debug error in MobX strict-mode Feb 22, 2020
@nighca nighca merged commit 8225fcc into qiniu:master Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant