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

Fix after hooks inside computed #1026

Merged
merged 6 commits into from
Sep 29, 2018
Merged

Conversation

xaviergonz
Copy link
Contributor

Closes #967

Requires mobx 4.5.0 || 5.5.0

Also included:

  • updated dependencies
  • fixed examples

@xaviergonz
Copy link
Contributor Author

@mweststrate does the requirement of mobx 5.5 / 4.5 make this a breaking change?

@xaviergonz
Copy link
Contributor Author

xaviergonz commented Sep 29, 2018

Avoided making it a breaking change by checking if the peer mobx version exposes the required functionality. Either way when installing the version and the wron mobx peer dep is installed yarn will issue a warn like [email protected]" has unmet peer dependency "mobx@>=4.5.0 <5.0.0 || >=5.5.0 <6.0.0"., but will work as it used to.

@xaviergonz
Copy link
Contributor Author

merging since the fix itself is pretty simple:

fireHook(name: string) {
        const fn =
            this.storedValue && typeof this.storedValue === "object" && this.storedValue[name]
        if (typeof fn === "function") {
            // we check for it to allow old mobx peer dependencies that don't have the method to work (even when still bugged)
            if (_allowStateChangesInsideComputed) {
                _allowStateChangesInsideComputed(() => {
                    fn.apply(this.storedValue)
                })
            } else {
                fn.apply(this.storedValue)
            }
        }
    }

the rest is just fixing the unmaintained examples and updating dev deps

@xaviergonz xaviergonz merged commit 4363896 into master Sep 29, 2018
@xaviergonz xaviergonz deleted the fix-after-hooks-inside-computed branch November 25, 2018 11:22
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.

afterCreate is firing when a computed accesses a child causing a side effect
1 participant