Best way to "ignore" observableRequiresReaction #3578
Answered
by
mweststrate
hitsthings
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Use action / runInAction
…On Wed, 16 Nov 2022, 23:53 Adam Ahmed, ***@***.***> wrote:
Hi I'm new to mobx. I am trying to ensure strict use of it in my app so
I've turned on all the linting and I'm going through each warning in the
logs.
Some cases where I am accessing an observable are in static spots where it
doesn't make sense to observe anything. For example, React Router has the
concept of a "loader" which really just runs once per route change. In
those cases, I want to explicitly suppress the console warning so I can
move on to the next problem. Is there any way to do that?
I tried untracked(() => ...) but that doesn't do it. I guess I could make
some kind of withConfiguration({ observableRequiresReaction: false }, ()
=> ....) to override configuration for the life of that callback. ...is
that the best way to go? Or is there something built-in for this?
—
Reply to this email directly, view it on GitHub
<#3578>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBEQ5T2QWXOAYPI5DWTWIVQVHANCNFSM6AAAAAASCX5JAQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hitsthings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I'm new to mobx. I am trying to ensure strict use of it in my app so I've turned on all the linting and I'm going through each warning in the logs.
Some cases where I am accessing an observable are in static spots where it doesn't make sense to observe anything. For example, React Router has the concept of a "loader" which really just runs once per route change. In those cases, I want to explicitly suppress the console warning so I can move on to the next problem. Is there any way to do that?
I tried
untracked(() => ...)
but that doesn't do it. I guess I could make some kind ofwithConfiguration({ observableRequiresReaction: false }, () => ....)
to override configuration for the life of that callback. ...is that the best way to go? Or is there something built-in for this?Beta Was this translation helpful? Give feedback.
All reactions