[v6] [Feature]: Guidance on animating out routes #8604
Unanswered
jamesplease
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Here's one way to do this with Framer's |
Beta Was this translation helpful? Give feedback.
2 replies
-
You can also refer this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the new or updated feature that you are suggesting?
Hey React Router team,
Thanks so much for your work on v6. It's clear a lot of effort went into it, and I think it turned out great.
I'm writing this issue because one of the things that I commonly need to do is animate out an element when the path no longer matches. I found it relatively straightforward to accomplish this in v5, as the Routes themselves are components that render their children. The v5 docs also included an example showing animated routes that was a useful foundation to build from.
In v6, though, it's not clear to me yet what the simplest way to accomplish exit animations is when using the
<Routes/>
/<Route>
/useRoutes
APIs.I was able to animate out in v6 when using the
useMatch()
API directly, but it seems that this approach is effectively going back to v5 patterns. This approach means that you lose out on all of the new features like outlets, and you also have to go without any the other useful v5 features such asSwitch
. Because of this, for an app with a lot of location-based exit animations it seems like it might actually be better to stay on v5 ifuseMatch
is currently the best way to do animated exit transitions in v6.If y'all have any recommendations on the best way to do exit animations with routes in v6, I think that could make for a pretty useful guide in the docs.
Also, although I'm definitely still learning the ropes of v6, I am beginning to wonder if new or updated APIs might make it easier to integrate Routes/Route/useRoutes with popular animation libs. I've been poking around the source and my initial thoughts were that something around
_renderMatches
could make it easier to integrate this lib with, say, Framer Motion'sAnimatePresence
. I'm still investigating this idea and I might jot down more ideas here if anything more specific comes to mind.It's also entirely possible that there's a super obvious way to do this with Routes/Route/useRoutes. I am definitely a beginner at v6 so do chime in if there's something simple that I've overlooked.
To summarize this issue:
Thanks for reading!
Why should this feature be included?
Animating out routes is a common requirement, so there should be a good story for it, I think.
Beta Was this translation helpful? Give feedback.
All reactions