forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.jsx
More file actions
32 lines (28 loc) · 729 Bytes
/
root.jsx
File metadata and controls
32 lines (28 loc) · 729 Bytes
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
import { useLoaderData, Link, Outlet } from "react-router-dom";
import { getNotes } from "../notes";
export async function loader() {
return getNotes();
}
export default function Root() {
const notes = useLoaderData();
return (
<div style={{ display: "flex" }}>
<div style={{ padding: "0 2rem", borderRight: "solid 1px #ccc" }}>
<h1>Notes!</h1>
<p>
<Link to="new">Create Note</Link>
</p>
<ul>
{notes.map((note) => (
<li>
<Link to={`/note/${note.id}`}>{note.title}</Link>
</li>
))}
</ul>
</div>
<div style={{ flex: 1, padding: "0 2rem" }}>
<Outlet />
</div>
</div>
);
}