aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.tsx
blob: 8845354e6bfae31c8b6c5a26f104d32832da2ae3 (plain) (blame)
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
import { useEffect, useState } from "react";
import Router from "./Router";
import { setNobelPrizes } from "./data";

let loadOnce = false;
function App() {
  const [loading, setLoading] = useState(true);
  useEffect(() => {
    (async () => {
      if (loadOnce === false) {
        loadOnce = true;
        await setNobelPrizes();
        setLoading(false);
      }
    })();
  }, []);

  if (loading) {
    return <>Loading nobel prizes</>;
  } else {
    return <Router />;
  }
}

export default App;