You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I might have found a bug, but I may also just be doing something wrong. I can't figure this behavior out.
Intended outcome:
Basically...
in the constructor, I am setting up a listener on the browser history from the history package.
I call navigateV2 on a button click.
The listener runs. It changes the state.
Observer components should rerender.
Actual outcome
Any calls to setRoute inside of that listener don't work. I tried:
calling it directly
running it inside of runInAction
calling setRoute inside of a setTimeout inside of the listener with varying delays.
wrapping the whole listener with action
setting the state directly rather than from setRoute. And changing individual keys of the current object, one at a time.
Additionally...
The listener DEFNITELY runs, calls setRoute, and changes the state. I confirmed that using console logs.
My components are DEFINITELY wrapped in observer and they run from any other state change. If I uncomment line 177, they update from that. Just not from any changes made within the listener.
Shouldn't this just work? If I've already confirmed that I set up the observer components correctly and they are rerendering from any other state change, I'm not sure why this, specifically, wouldn't work. It's not on all callbacks in my application, either, just this one.
I even see that setRoute is being run inside of MobX devtools:
How to reproduce the issue:
I'm sorry, I'm not sure how to reproduce this. I tried to set up something similar in a fresh project with the same compiler settings, but it seems to work perfectly... I'm so confused. Is there something I could be doing elsewhere with mobx that interferes with this listener state change notifying observers??
Versions
"mobx": "^6.10.0",
"mobx-react": "^9.0.0",
The text was updated successfully, but these errors were encountered:
jaekwak02
changed the title
State change triggered from callbacks are ignored... under some circumstances?
State change triggered from callbacks do not notify observers... under some circumstances?
Jul 30, 2023
I found the workaround for my situation, which is to mount the listener on useEffect.
I tried to find a minimal reproducible example, but I'm sorry, I just couldn't find any scenario where this happened outside of the one place I encountered it.
I might have found a bug, but I may also just be doing something wrong. I can't figure this behavior out.
Intended outcome:
Basically...
history
package.navigateV2
on a button click.Actual outcome
Any calls to
setRoute
inside of that listener don't work. I tried:runInAction
setRoute
inside of a setTimeout inside of the listener with varying delays.action
current
object, one at a time.Additionally...
setRoute
, and changes the state. I confirmed that using console logs.observer
and they run from any other state change. If I uncomment line 177, they update from that. Just not from any changes made within the listener.Shouldn't this just work? If I've already confirmed that I set up the observer components correctly and they are rerendering from any other state change, I'm not sure why this, specifically, wouldn't work. It's not on all callbacks in my application, either, just this one.
I even see that setRoute is being run inside of MobX devtools:
How to reproduce the issue:
I'm sorry, I'm not sure how to reproduce this. I tried to set up something similar in a fresh project with the same compiler settings, but it seems to work perfectly... I'm so confused. Is there something I could be doing elsewhere with mobx that interferes with this listener state change notifying observers??
Versions
The text was updated successfully, but these errors were encountered: