-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
67 lines (62 loc) · 1.69 KB
/
index.html
File metadata and controls
67 lines (62 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React Client-Side Routing</title>
<!-- Load Babel Standalone -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel" data-type="module" data-presets="react">
// Import React, ReactDOM, and Remix Router
import React from "https://esm.sh/react@18";
import ReactDOM from "https://esm.sh/react-dom@18";
import { createBrowserRouter, RouterProvider, Link } from "https://esm.sh/react-router-dom@6";
// Home component
const Home = () => (
<div>
<h1>Home Page</h1>
<p>Welcome to the Home Page!</p>
<nav>
<Link to="/about">Go to About</Link>
</nav>
<Footer />
</div>
);
// About component
const About = () => (
<div>
<h1>About Page</h1>
<p>This is the About Page.</p>
<nav>
<Link to="/">Go to Home</Link>
</nav>
<Footer />
</div>
);
// Footer component
function Footer() {
return (
<pre>Just view source of this page (index.html) and you will see all of the code there, easy to follow and learn.</pre>
)
}
// Define routes using Remix Router
const router = createBrowserRouter([
{
path: "/",
element: <Home />
},
{
path: "/about",
element: <About />
}
]);
// Render the application
ReactDOM.createRoot(document.getElementById("root")).render(
<RouterProvider router={router} />
);
</script>
</body>
</html>