Answer the question
In order to leave comments, you need to log in
Nested routing without component in child elements?
I need the path of the child element to be added to the url, but there was no permanent component. So that after clicking on the link "elena" the url would be "users/elena" and go to the Elena() component. Can it be done?
function Users() {
return (
<div>
<Link to="elena"></Link>
<Link to="oleg"></Link>
</div>
);
}
function App() {
return (
<Routes>
<Route path="/users" element={<Users />}>
<Route path="elena" element={<Elena />} />
<Route path="oleg" element={<Oleg />} />
</Route>
</Routes>
);
}
Answer the question
In order to leave comments, you need to log in
It turned out like this:
function App() {
return (
<Routes>
<Route path="/users" >
<Route path="" element={<Users />} />
<Route path="elena" element={<Elena />} />
<Route path="oleg" element={<Oleg />} />
</Route>
</Routes>
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question