I have inputted a route for invalid path handling. For example if a user goes to
"/random-unattributed-path" which hasn't been outlined in the router.
It works great, bar a single issue I have found so far.
This is the code I inserted:
<Router>
<Routes>
<Route path="/" element={[<Navigation key={0}/>, <Home key={1} />]} />
<Route
path="/AboutUs"
element={[<Navigation key={0} />, <AboutUs key={1} />]}
key={0}
/>
<Route
exact
path="/Profile/:id"
element={[<Navigation key={0}/>, <Profile key={1} />]}
/>
<Route
path="/Profile"
element={[<Navigation key={0} />, <Profile key={1} />]}
/>
<Route path="*" element={[<NotFound />]} />
{/* THIS LINE RIGHT HERE ^^^^^^^^^^^^ */}
</Routes>
</Router>
What I have found, is that when you redirect from one path & element to another, is that it will very very briefly show the notFound element.
I have an example to show this problem here: https://giphy.com/gifs/9ZcdbA169kJy48QB4b/fullscreen
This Code-sandbox demonstrates the code but not the issue, maybe it has something to do with how Code-sandbox works or in my case of the issue, something to do with local-hosting deployment. https://codesandbox.io/s/frosty-tereshkova-ptb6nn?file=/src/Other.js
This shows going from /profile/:id to /profile back to /profile/:id