Thanks to Anxin.Y for the article about making a transition DIY through animation on React-router v5.
Now, I will try to make it with v6.
...
For further actions, you may consider blocking this person and/or reporting abuse
If i may, i was inspired by ur post and i tried to make it more flexible...
MainContent.js :
Styles for animations
Regards,
Fred, Brittany - France
YOU ARE AMAIZING! >.<
An issue here is that you are only displaying one view at a time.
What happens if you want to animate a route, mobile/native style, where one view slides in over another?
I am on something close here. The new React Router 6 has
useOutlet
where it will give you the current element in that outlet that that you are rendering.You can store that element stack in a
ref
and then when the navigation changes, use that stashed ref (which will be the old outlet results as the outlet will be updated) and then you render that under your new outlet with your animation triggering over.Obviously, if you have nested outlets and a mixture of tabs/menus/stacks your back-navigation will get tricky. Still, you it should be on the right direction.
Thank you!!! This is exactly what I needed, a DYI approach. Found some tutorials, but they needed Framer Motion or another libraries... Learned something new today 😅
Thank you! Love how you included a working code sandbox. It's very useable!
can you update this for the v6.4 + syntex ?
How can I do that with nested routes?
I like it!!!
Thanks for this article! With what I've learnt from this article I was able to create page transitions with GSAP.
This is aweesome, thanks. Just I have the same code as you but i get an error as it renders multiple times, is there any fix to it? or am i dooing something wrong.
Again thank you
Wow dude, I came from using react-transition-group, but since react router v6 arrived, this beautiful method is my salvation. Nice work of @anxiny and yours!
Thanks! Glad I can help 😊. Nice article!