title: React-router-dom (v6) with Framer Motion (v4)
body: <p>I am trying to update my react-router-dom to v6, but it seems to be causing issues with framer motions AnimatePresence, specifically the exit transition.</p>
  <p>In App.js:</p>
  <pre><code>import { Routes, Route } from &quot;react-router-dom&quot;;
  import {AnimatePresence} from &quot;framer-motion&quot;;  
  
  import Home from &quot;./Components/Home&quot;;
  import About from &quot;./Components/About&quot;;
  function App() {
    return (
      &lt;div className=&quot;App&quot;&gt;
  
        {/* globals such as header will go here  */}
  
        &lt;AnimatePresence exitBeforeEnter&gt;
          &lt;Routes&gt;
            &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
            &lt;Route path=&quot;about&quot; element={&lt;About /&gt;} /&gt;
          &lt;/Routes&gt;
        &lt;/AnimatePresence&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>And then in my About/Home components I have:</p>
  <pre><code>import {Link} from &quot;react-router-dom&quot;;
  import {motion} from &quot;framer-motion&quot;;  
  
      function About() {
      
          const pageMotion = {
              initial: {opacity: 0, x: 0},
              animate: {opacity: 1, x: 50, transition: {duration: 2}},
              exit: {opacity: 0, x:0, transition: {duration: 2}}
          };
      
          return (
              &lt;div className=&quot;about&quot;&gt;
                  &lt;motion.div initial=&quot;initial&quot; animate=&quot;animate&quot; exit=&quot;exit&quot; variants={pageMotion}&gt;about page&lt;/motion.div&gt;
                  &lt;Link to=&quot;/&quot;&gt;Go to home page&lt;/Link&gt;
              &lt;/div&gt;
          )
      }
      
      export default About
  </code></pre>
  <p>The &quot;initial&quot; and &quot;animate&quot; work fine, but exit is ignored, and immedietly jumps to the relevant page (rather than animating out first).</p>
  <p>Note: I also have had to downgrade to framer-motion v4, as v5 does not work with Create-react-app.</p>
  <p>Any help is appreciated.</p>