How to disable warning about "outside a reactive context"? #3213
Replies: 3 comments
-
Both The only problem is that atm mobx/packages/mobx/src/core/computedvalue.ts Lines 296 to 301 in 1174004 therefore, it can't be used to opt-out of global behavior (only opt-in if global is false). I think we can change that. |
Beta Was this translation helpful? Give feedback.
-
PR: #3214 |
Beta Was this translation helpful? Give feedback.
-
Ah, I completely missed that Btw there is related issue: mobxjs/mobx-utils#268 |
Beta Was this translation helpful? Give feedback.
-
MobX outputs the following warning when calling a
computedFn
outside of a reactive context:The same thing happens for
createTransformer
Fair enough; but for my case, knowing the downside (that in these circumstances the function will just act as if
computedFn
had not been used), I still want to proceed in doing this without creating console noise. I know settingkeepAlive
will get rid of the warning, but that's not what I want to do because it changes the behavior. I want the current behavior, just without the warning.Is there a way to suppress this warning? I couldn't find anything in the docs for
configure()
For prior art, this looks very similar to what
computedRequiresReaction
does:https://mobx.js.org/configuration.html
So I guess my request is for a
computedFnRequiresReaction
flag, or something like thatEdit: It seems from reading the source like maybe this can be done on a per-call basis by passing a second argument with options, and doing this?
mobx/packages/mobx/src/core/computedvalue.ts
Line 41 in 4ac6b45
Beta Was this translation helpful? Give feedback.
All reactions