mobx-utils
mobx-utils copied to clipboard
Make computedFn Warnings Optional?
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?
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 .
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.