forked from btholt/complete-intro-to-react-v5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
28 lines (25 loc) · 796 Bytes
/
App.js
File metadata and controls
28 lines (25 loc) · 796 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
import React, { useState, lazy, Suspense } from "react";
import ReactDOM from "react-dom";
import { Router, Link } from "@reach/router";
import ThemeContext from "./ThemeContext";
const Details = lazy(() => import("./Details"));
const SearchParams = lazy(() => import("./SearchParams"));
const App = () => {
const theme = useState("darkblue");
return (
<ThemeContext.Provider value={theme}>
<div>
<header>
<Link to="/">Adopt Me!</Link>
</header>
<Suspense fallback={<h1>loading route …</h1>}>
<Router>
<SearchParams path="/" />
<Details path="/details/:id" />
</Router>
</Suspense>
</div>
</ThemeContext.Provider>
);
};
ReactDOM.render(<App />, document.getElementById("root"));