relay
relay copied to clipboard
`refetch({}, "network-only")` suspends, even when inside `startTransition`
Reporting issues with Relay
refetch({}, "network-only")
always causes React to suspend, even when inside startTransition
. This is annoying, specially when rendering lists with usePaginationFragment
, where you would want to show the existing items, while re-fetching the new ones, and not jump to a suspend boundary. Furthermore, I think the difference in behavior for different FetchPolicy
s is not that intuitive for a beginner. And loadNext
, for example, will never suspend. I think everything that makes a network request should suspend, to avoid these confusions, and the user should be able to opt out of it with startTransition
. This was the approach Apollo took (https://github.com/apollographql/apollo-client/issues/10676).
I realize this might be too dramatic of a change, but at least we should be able to use startTransition
to prevent refetch
from suspending.
@Zizico2 did you ever figure out a fix for this?
Seems like refetch
ignores startTransition
regardless of the fetchPolicy
.
I'm on 16.2.0.
Was useTransition
introduced before React 18? You may be importing an API compatible version of useTransition
from {somewhere} that's actually a noop.
Sorry I meant 16.2.0 react-relay. I'm on 18.2.0 react.