-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usePaginationFragment's refetch triggers twice when using useTransition #3082
Comments
I'm not sure if but we got the same issue when using |
Did you managed to fix it or come up with a workaround? At the moment I've just commented out the transitions and let the component suspend, it's a horrible user experience but having the wrong data display is worse. Holding back on going live with it until I can figure out a solution to this. |
one way to fix this is to move the suspend part to another component, and have another error boundary |
Thanks for the detailed issue, this definitely sounds like a bug. Just to confirm, were you using the absolute latest version of each package you mentioned? |
At the time I believe these were the latest, although I see newer versions have been released since. At this time I'm avoiding changing package versions as I've QA'd all of the functionality added with the experimental packages and upgrading to a newer experimental package would require a bit of work. So I'm holding off for a release version or enough changes on an experimental branch to justify the time to QA it all again. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Related? #4526 |
I found out that `useTransition` doesn't work when using `usePaginationFragement`. To get it to work the way it's intended in the tutorial I had to use `isLoadingNext` boolean prop that is returned from `usePaginationFragement` instead. Not sure if this a bug, or by design. As a beginner, I spent quite some time trying to figure out why my code wasn't working, after a bit of digging I ran into some potenially related issues: - facebook#4531 (comment) - facebook#4526 - facebook#3082 In this PR I've updated the "Improving the Loading Experience with useTransition" example not to confuse newcomers.
I'm using the following
experimental
versions when running encountering this issue.I've been following the reference and seem to be hitting a strange bug. https://relay.dev/docs/en/experimental/api-reference#usepaginationfragment
I'm loading a component which is supplied with preloaded data, I'm then displaying that data in a list and allowing a user to change the
orderStatus
as a filter for that data.I'm using the
usePaginationFragment
hook and therefetch
method from that. All of that seems to work as intended but does suspend the component which is expected.Applying a
useTransition
hook around therefetch
causes some strange behaviour.It seems the first change works as intended, but subsequent changes causes the
refetch
to trigger again and call theonComplete
method.I've tried commenting out the
startTransition
and it works fine but suspends, enabling it again causesrefetch
to trigger twice.In the code above, following these steps it reproduces the issue.
all
toopen
TRANSITION:open
,REFETCH:open
,<REQUEST SENT:open>
,COMPLETE:open
open
tocomplete
TRANSITION:complete
,REFETCH:complete
,<REQUEST SENT:open>
,COMPLETE:open
,<REQUEST SENT:complete>
,COMPLETE:complete
complete
toall
TRANSITION:all
,REFETCH:all
,<REQUEST SENT:complete>
,COMPLETE:complete
,<REQUEST SENT:all>
,COMPLETE:all
The initial load appears to work just fine, but any changes after that cause duplicate requests to be sent. The strange part is it's not like the function in
startTransition
is calling twice else you'd seeREFETCH
called twice as well, so it's just therefetch
function itself calling some how, which then calls theonComplete
callback function.Any help with this would be greatly appreciated, let me know if you require any further details.
The text was updated successfully, but these errors were encountered: