On the React Router Dom v5 I had a working code where I could use the nested elements. V5 Code was:
const App = () => {
return (
<Router>
<Switch>
<Route exact path="/" />
{user && (
<>
<Route path="/movies">
<Home type="movie" />
</Route>
<Route path="/series">
<Home type="series" />
</Route>
</>
)}
</Switch>
</Router>
);
};
... Now when I am trying to move to V6 version I cant access the content of nested page. These two nested routes showing the content based on "type" attribute, but in v6 I dont get any content at all. What I see, is only the home page. When I am trying to navigate through the navbar, only link is changing, but I cant access the content of the type element.
My current v6 code:
App.jsx:
const App = () => {
return (
<Router>
<Routes>
<Route path="/" element={<Home />} >
<Route path="/movies" element={<Home type='movies'/>} />
<Route path="/series" element={<Home type='series'/>} />
</Route>
</Routes>
</Router>
);
};
Home.jsx:
const Home = ({type}) => {
return (
<div className='home'>
<Navbar />
<Featured type={type} />
<List />
<List />
<List />
<List />
<Outlet />
</div>
)
}
Can someone, please help me to understand what I am doing wrong and why react router does not load the content of the component?