Framer motion's full page transitions breaks with remix while using loader in route file
See original GitHub issueWhat version of Remix are you using?
1.6.3
Steps to Reproduce
- Make simple remix app with framer-motion
- Set up page transtions in root
- make route that uses loader data,
Expected Behavior
I expected animation to be compled (exiting from page with loader data).
Actual Behavior
While exiting from page with loader data, it gives an error TypeError: Cannot destructure property 'data' of 'useLoaderData(...)' as it is undefined.
. I noticed that loader data delets first off, not allowing animation to complete, so error shows.
All other routes with no loader works completly fine! made clean and simple new remix app with framer motion to show
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Page Transitions with React Router and Framer Motion
Whats up everyone! Hope you all are doing well. In this episode we create a really cool page transition using framer motion and...
Read more >Remix-Run Page Transition Animation With Framer Motion
I'm super new to Remix, but here's a really simple example of what I did to get route animations working. root.jsx. import {...
Read more >Examples | Framer for Developers
Simple examples for animation, gestures, components, transforms and more.
Read more >Adding route transition animations in Remix
The easiest way I found to do this, is using Framer Motion. By wrapping all of my content with the <AnimatePresence /> component,...
Read more >Framer Motion examples for React animations - Refine Dev
When a tool like Framer Motion is available, why write many lines of CSS code to create an animation? Web applications look more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, that’s not gonna work, as react will remove it from the tree and framer will just animate the new outlet. For a simple case like this one you could work around it the way you first did it, keeping exit animations, but that loses the message when exiting the route. To also keep the loader message when the loader is exiting, you could use
useRef
.Another “workaround” is to load the message in the root loader, since that routeData is always available, and then use
useMatches()
inside the index route.The best thing it seems would be to prevent the route transition before framer motion finishes animating, but I haven’t figured out yet if that is available to us.
I made one with loader bug. U can try yourself - change
<AnimatePresence exitBeforeEnter> <motion.main key={location.key}> {outlet} </motion.main> </AnimatePresence>
to<AnimatePresence exitBeforeEnter> {outlet} </AnimatePresence>
to remove animations and It’ll work fine