Can we intercept navigations on a global or per-route basis to add viewTransitions/state? #14859
Replies: 0 comments 1 reply
-
|
Yes — React Router v7 (which Remix is now built on) supports this. Here are the approaches from simplest to most flexible: 1. Global
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently using client side routing with a Data Router. I want to start making use of viewTransitions, but adding a viewTransition prop to every navigate, Navigate, Link, and NavLink is very annoying and not super feasible. Similarly, I would like some global state on our navigations (like a
fromstate that specifies the previous path)My first instinct is to make wrapper functions/components of each that provide the default behavior that I want, but that's annoying to maintain and I would prefer the direct API.
My second thought was using middleware to intercept navigations and apply the state and props, but it doesn't seem like we are allowed to change the navigation from middleware.
Are there any more recommended ways to implement this?
Beta Was this translation helpful? Give feedback.
All reactions