You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a React project that uses React Router v6 for client-side routing. I have a routing configuration that looks like this:
App.tsx.
functionApp(): JSX.Element{return(<><NavBar/><Routes><Routepath="/"element={<Layout/>}><Routeindexelement={<Home/>}/><Routepath="/about"element={<About/>}/><Routepath="/contact"element={<Contact/>}/><Routepath="/*"element={<NotFound/>}/></Route><Routepath="/foo"element={<div>foo is an individual page!</div>}/></Routes></>);}exportdefaultApp;constLayout=(): JSX.Element=>{return(<><Outlet/></>);};
The NavBar and Routes components are working fine, and the Layout component is being rendered correctly with its child routes.
However, I have a problem with the /foo route. When I navigate to /foo, the <div> element with the text "foo is an individual page!" is rendered as a child of the Layout component in DOM, but I want it to be a peer of the / structure rather than under /.
Is there a way to modify my routing configuration to achieve this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm currently working on a React project that uses React Router v6 for client-side routing. I have a routing configuration that looks like this:
App.tsx
.The NavBar and Routes components are working fine, and the Layout component is being rendered correctly with its child routes.
However, I have a problem with the
/foo
route. When I navigate to/foo
, the<div>
element with the text "foo is an individual page!" is rendered as a child of the Layout component in DOM, but I want it to be a peer of the/
structure rather than under/
.Is there a way to modify my routing configuration to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions