I am coding a simple app and I wanted to add Page Transitions using framer-motion library. The problem that I'm facing is that every tutorial and documentation that I see, uses the <motion.div> tag inside each component, which I find kind of annoying.
This is the return of my App.js
return (
<Router>
<div className="App">
<Switch>
<Route exact path="/">
<HomeScreen />
</Route>
<Route exact path="/contact">
<ContactScreen />
</Route>
<Route exact path="/aboutus">
<AboutUsScreen />
</Route>
</Switch>
</div>
</Router >
);
If I would want to add the animation, I'd have to add <motion.div> inside each component. What I'm looking to do (and not being able to make it work) is something like this:
<Route exact path="/">
<motion.div initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<HomeScreen />
</motion.div>
</Route>
I've been stuck at this since last week. If someone could give me a hand with this, I'd be really grateful!