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
If I click a link to /slow, URL will change to /slow and will wait three seconds before going back to /good (because of aborted transition).
However if I click a link to /slow and then perform a Back myself (which will immediately change address to /good), the router will still invoke goBack, potentially throwing me out of the website.
Similarly, if I get tired of waiting and click a link to /another, when /slow is ready and its transition.abort() runs, it will force going back when I'm neither on /good nor on /slow anymore.
This is not just a problem with abortions: even if I just have a slow transition.wait() and click on a link while I'm waiting for transition to happen, router will happily take me there, but then all of a sudden will force the transition on me.
I propose the following rule of thumb for solving race problems in router: user intent must always override pending transitions. In other words, user clicking Back or clicking on a link should abort the pending transition. This behavior is most natural and matches what browser does.
I'm preparing a PR for that.
The text was updated successfully, but these errors were encountered:
Previously, navigating (by clicking Back button or a link) while a transition in progress would put router into an inconsistent state.
Now, a pending transition will be aborted and ignored by the router if user navigates away while it was pending.
Fixesremix-run#479
Router currently doesn't handle races between user actions and transitions well.
Say I'm on route
/good
, and/slow
handler has this code (assumingabort()
is fixed of course):If I click a link to
/slow
, URL will change to/slow
and will wait three seconds before going back to/good
(because of aborted transition).However if I click a link to
/slow
and then perform a Back myself (which will immediately change address to/good
), the router will still invokegoBack
, potentially throwing me out of the website.Similarly, if I get tired of waiting and click a link to
/another
, when/slow
is ready and itstransition.abort()
runs, it will force going back when I'm neither on/good
nor on/slow
anymore.This is not just a problem with abortions: even if I just have a slow
transition.wait()
and click on a link while I'm waiting for transition to happen, router will happily take me there, but then all of a sudden will force the transition on me.I propose the following rule of thumb for solving race problems in router: user intent must always override pending transitions. In other words, user clicking Back or clicking on a link should
abort
the pending transition. This behavior is most natural and matches what browser does.I'm preparing a PR for that.
The text was updated successfully, but these errors were encountered: