Skip to content

Commit 4649df3

Browse files
authored
Merge pull request #21 from CodeCafeCommunity/20-add-react-router
Add React Router to app
2 parents 37231e2 + 20820ab commit 4649df3

File tree

3 files changed

+69
-8
lines changed

3 files changed

+69
-8
lines changed

package-lock.json

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"dependencies": {
1313
"react": "19.0.0",
14-
"react-dom": "19.0.0"
14+
"react-dom": "19.0.0",
15+
"react-router": "^7.1.1"
1516
},
1617
"devDependencies": {
1718
"@eslint/js": "^9.17.0",

src/main.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
3+
import { BrowserRouter } from "react-router";
34
import "./index.css";
45
import App from "./App.tsx";
56

6-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7-
createRoot(document.getElementById("root")!).render(
8-
<StrictMode>
9-
<App />
10-
</StrictMode>,
11-
);
7+
const root = document.getElementById("root");
8+
9+
if (root) {
10+
createRoot(root).render(
11+
<StrictMode>
12+
<BrowserRouter>
13+
<App />
14+
</BrowserRouter>
15+
</StrictMode>,
16+
);
17+
} else {
18+
throw new Error("Failed to find root element");
19+
}

0 commit comments

Comments
 (0)