Repository navigation
Replies: 1 comment
|
Update: same repro in framework mode ( Framework mode always commits
The results are the same with So in framework mode there is currently no way to give a navigation a direction with |
|
Update: same repro in framework mode ( Framework mode always commits
The results are the same with So in framework mode there is currently no way to give a navigation a direction with |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
8.5 deprecates the router's view transition APIs in favor of React's
<ViewTransition>(#15493). Following the migration guide, the cross-fade case works. But there's no migration path yet for directional page transitions, and we'd like one before the legacy API goes away in v9.Repro: https://stackblitz.com/edit/vitejs-vite-fhmxctzv (React 19.3, react-router 8.5.0, data router, Chromium). Open the preview in its own tab; an in-app guide walks through 5 scenarios and checks each result.
Use case
App-like, mobile-first site (also embedded in native WebViews) with directional full-page transitions:
navigate(-1), in-app back buttons)hasUAVisualTransition)Today we build this on the legacy
viewTransitionoption plusdocument.startViewTransitiontypes.Why current APIs are insufficient
With a persistent
<ViewTransition update={{ forward: 'forward', backward: 'backward', default: 'auto' }}>around<Outlet>:startTransition(() => { addTransitionType('forward'); navigate(to) })only works when the navigation resolves synchronously (no loader, nolazy). Otherwise the router commitsnavigation.state = "loading"inside our transition and the new page later in a transition without types, so the page swap runs withtypes: null(repro scenarios 1 vs 3). In framework mode this happens for every navigation, even without a loader (see comment below). If the layout re-renders on navigation state (e.g.useNavigation()for a global loading indicator), theloadingcommit even starts its own view transition over unchanged content, which gets the types (scenario 2; see <ViewTransition>: the router's "loading" commit starts an extra view transition that takes the transition types and delays the page swap #15670).popstateevent synchronously (as the guide notes). In framework mode they do animate, still without types.hasUAVisualTransitionis true.Possible API
navigate(to, { transitionTypes: ['forward'] }),<Link transitionTypes={[...]}>,<Form transitionTypes>: the router callsaddTransitionTypeinside the transition that commits the new location (not theloadingone).getTransitionTypes({ currentLocation, nextLocation, historyAction, delta, hasUAVisualTransition }) => string[] | false. It covers back/forward direction and lets apps opt out on UA gestures (false).<ViewTransition>boundary is present, or document how a router can follow React's "View Transition enabled router" guidance.Happy to help test an
unstable_implementation.All reactions