mobx-utils icon indicating copy to clipboard operation
mobx-utils copied to clipboard

Make computedFn Warnings Optional?

Open destinmcmurry opened this issue 3 years ago • 2 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?

destinmcmurry avatar Jul 22 '20 14:07 destinmcmurry

Feel free to PR an option to suppress the warning

On Wed, 22 Jul 2020, 15:29 Destin, [email protected] wrote:

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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-utils/issues/268, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBGYUMATIIBABMWTWF3R43ZTHANCNFSM4PEYRHDQ .

mweststrate avatar Jul 22 '20 14:07 mweststrate

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.

urugator avatar Dec 05 '21 12:12 urugator