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
Currently RR uses React.startTransition so if you have a clientLoader that returns promises and doesn't await for anything, the navigation.state goes back to idle immediately, making it hard to show loading feedback while using with Suspense.
Userland code has to wrap the navigation calls from RR in another startTransition from useTransition in order to access the isPending state.
If React Router switch to useTransition internally, its possible to expose a boolean like isTransitioning from the useNavigation hook that can be used by userland code, avoiding adding unnecessary code.
My main use case is that, if I have a page with some static content, a dynamic table and pagination content, I want to show a spinner when initially loading the page in place of the body and the pagination, but when user changes some search parameters (seach, page, etc...) I want only the body page to show the spinner, but the rest of the page, including the pagination stay as is.
The key on the Suspense should've done the trick, but React never suspend the Suspense wrapping the body when there are other sibling Suspense boundaries that hasn't suspended (namely, the Suspense wrapping the Pagination).
Even though React could improve this, I think exposing the transition state is still a good addition.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently RR uses
React.startTransition
so if you have a clientLoader that returns promises and doesn't await for anything, thenavigation.state
goes back toidle
immediately, making it hard to show loading feedback while using with Suspense.Userland code has to wrap the navigation calls from RR in another startTransition from
useTransition
in order to access the isPending state.If React Router switch to
useTransition
internally, its possible to expose a boolean likeisTransitioning
from theuseNavigation
hook that can be used by userland code, avoiding adding unnecessary code.My main use case is that, if I have a page with some static content, a dynamic table and pagination content, I want to show a spinner when initially loading the page in place of the body and the pagination, but when user changes some search parameters (seach, page, etc...) I want only the body page to show the spinner, but the rest of the page, including the pagination stay as is.
The
key
on the Suspense should've done the trick, but React never suspend the Suspense wrapping the body when there are other sibling Suspense boundaries that hasn't suspended (namely, the Suspense wrapping the Pagination).Even though React could improve this, I think exposing the transition state is still a good addition.
Here is a Stackblitz example: https://stackblitz.com/edit/react-router-react-19-suspense?file=app%2Froutes%2Fno-key-and-use-transition.tsx
Beta Was this translation helpful? Give feedback.
All reactions