useOutlet Hook (for animated outlets) #1831
ViewableGravy
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
sounds interesting! |
Beta Was this translation helpful? Give feedback.
3 replies
-
Is there any new progress on this issue? |
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
-
My company is currently looking at migrating to Tanstack router from react router v5. One of the things that we have identified as a potential issue is route transition animations and how the approach would differ from v5's.
There is a discussion post on how you could potentially use current options to implement this, but the accepted answer suggests cloning the router during the animation phase so that outlets render previous elements (since the router context would be the pre-navigation context). This solution doesn't particularly feel like a good approach in my opinion and so instead we were looking at other more robust options:
#823
One such approach that is used in react-router v6 is to use their
useOutlet
hook to get back a reference to the element and then check for whether this element changes reference. This would allow for easily creating a custom<AnimatedOutlet>
component or any other variation of the Outlet without requiring the internal functionality to be reimplemented (and potentially desynced from the libraries implementation).Would adding a
useOutlet
hook be something that could be considered in the future? Realistically from what I can see, internally the Outlet component just does some checks and returns a nextMatch or nextMatch wrapped in a suspense boundary, so I'd imagine a use outlet would do the exact same thing, but would leave the memoization and handling of the final rendered component up to the consuming component.I'm happy to make an example PR of what this might look like if this is something that maintainers think would benefit the library.
Note: I made this a separate discussion message to the above linked discussion because a useOutlet hook does not specifically apply to animations, although it is one use case, any custom Outlet implementation would ideally be able to access this logic.
Beta Was this translation helpful? Give feedback.
All reactions