#Using Nav.Link
1 messages · Page 1 of 1 (latest)
I do not have <Router>
Links arent showing up due to that error
ok, and just making sure, you are using React Router and not Remix, correct?
Correct
and this is RR 6.4?
do you have a <RouterProvider> like it says in the tutorial?
that error could stand to be updated, it's now <RouterProvider> and not <Router>
I believe I have 6.4
in main.tsx?
yeah, I mean basically you want it at the top level of your app where you call React's render()
you need to call
const router = createBrowserRouter([ /* route config */ ])
and set up your route config there, and pass that to RouterProvider
I made it, and when it means children. Is that similar pages to the same path? I added a few more links, they dont show up or do anything
what did you pass in to createBrowserRouter as the route config?
const router = createBrowserRouter([
{
path: "/",
element: <App />,
children: [
{
path: "/home",
element: <Home />,
},
{
path: "/about",
element: <About />,
},
{
path: "/store",
element: <Shop />,
},
]
}
])
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<RouterProvider
router={router}
fallbackElement={<App />}
/>
)
children means routes underneath a path segment. so if you wanted /abc and /abc/def you could either do
[
{
path: 'abc',
children: [{ path: "def" }]
}
]
or
[
{ path: 'abc' },
{ path: 'abc/def' },
]
oh!
I'm guessing your <App> doesn't have an outlet
what's in it
the outlet is where the children would render
it only has <Navbar /> & Container
ah that makes sense then. put <Outlet /> in the container
home, about, and shop will show up in there
from router?
don’t know what you mean
It doesn't know what Outlet is from
you have to import it from react-router-dom
that is what i meant, when I said from router. Sorry
it is really better to start from what the tutorial says to do
then add your pages to something that’s already working
Links are not showing up. I will figure it out. Im rushing it.