-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
51 lines (43 loc) · 1.16 KB
/
App.tsx
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
import { useState, useEffect } from "react";
import { Menu, DocumentStore, Viewer, mockData } from "react-documenter";
import { useNavigate, Routes, Route, BrowserRouter } from "react-router-dom";
import "./App.css"
export default function App() {
const navigate = useNavigate();
const [store, setStore] = useState(null);
useEffect(() => {
const newStore = new DocumentStore();
mockData.forEach((page) => newStore.set(page));
setStore(newStore);
}, []);
if (!store) return "Loading..."
return (
<section style={{
display: "flex"
}}>
<Menu
collapsible={false}
store={store}
linkAs="a"
linkHrefProp="href"
onLinkClick={navigate}
/>
<Routes>
{store.getNormalized().map((page, index) => (
<Route
key={index}
path={page.url}
element={
<Viewer
pages={store.getNormalized()}
currentPage={page}
onPrevClick={navigate}
onNextClick={navigate}
/>
}
/>
))}
</Routes>
</section>
);
}