mobxjs / mobx-utils

Utility functions and common patterns for MobX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make computedFn Warnings Optional?

destinmcmurry opened this issue · comments

Getting tons of the warning "invoking a computedFn from outside an reactive context won't be memoized, unless keepAlive is set" due to calling methods that use computedFns inside tests.

Ex: Test calls something like:

` handleSelection = (id) => {
        this.isSelected(id) ? this.deselect(id) : this.select(id);
 };`

to set up test case. And because isSelected is a computedFn, there's a warning for each time it's invoked. I see how these warnings are useful, but would it be possible to make them optional for cases like this?

Should it respect requiresReaction or global computedRequiresReaction (meaning it wouldn't warn by default)?
Or maybe requiresReaction === false could be used as override - true or undefined would have no effect on the warning.