Skip to content

Commit 135d2dc

Browse files
committed
Add index child route
1 parent 3b9a594 commit 135d2dc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/main.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
44
// import Root from './routes/root';
5+
import Index from './routes'
56
import ErrorPage from './error-page';
67
import Contact from './routes/contact';
78
import Root, {
@@ -23,6 +24,7 @@ const router = createBrowserRouter([
2324
loader: rootLoader,
2425
action: rootAction,
2526
children: [
27+
{index: true, element: <Index />},
2628
{
2729
path: 'contacts/:contactId',
2830
element: <Contact />,

src/routes/index.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function Index() {
2+
return (
3+
<p id="zero-state">
4+
This is a demo for React Router.
5+
<br />
6+
Check out{" "}
7+
<a href="https://reactrouter.com">
8+
the docs at reactrouter.com
9+
</a>
10+
.
11+
</p>
12+
);
13+
}

0 commit comments

Comments
 (0)