UI out of sync with data when triggering action + navigation #3293
Unanswered
emilbryggare
asked this question in
Q&A
Replies: 2 comments 1 reply
-
I just stumbled on this behavior again for another use case, but similar flow e.g. a fetcher.Form submit quickly followed by Link navigation. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This happens because Remix is aborting the previous request, but your Link navigation is happening faster than what the server takes to process the previously aborted request (an aborted request is still processed server-side). You could disable all links/forms until a navigation finish. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Excalidraw: https://excalidraw.com/#json=2YJ09LuQWiHc9vppzuOYn,Sm1WoU1qqSyDRt50cuVtFA
In my app, I’ve a listing page and detail page that show the number of votes a post has received. Reddit style.
I’m using useFetcher to vote and Link to navigate to the post detail page. If I click on the vote button (fetcher) and then Link (very fast) the resulting UI will (sometimes) end up out of sync with the database, When the Link navigation happens before the fetchers action has saved the data in the database the resulting UI will be out of sync with the database. The data revalidations that the fetcher triggers are canceled by the browser.
Reproduction here https://github.com/emilbryggare/remix-race-condition. I added a sleep in the fetchers action to make it easier to trigger.
Adding comment from @kiliman on the Discord:
Any tips on how to handle this? (Except for making the backend faster...)
Beta Was this translation helpful? Give feedback.
All reactions