otterscan/src/App.tsx

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-07-01 18:21:40 +00:00
import React, { Suspense } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "./Home";
import Search from "./Search";
import Title from "./Title";
2021-07-09 05:07:20 +00:00
import { RuntimeContext, useRuntime } from "./useRuntime";
2021-07-01 18:21:40 +00:00
const Block = React.lazy(() => import("./Block"));
const BlockTransactions = React.lazy(() => import("./BlockTransactions"));
const AddressTransactions = React.lazy(() => import("./AddressTransactions"));
const Transaction = React.lazy(() => import("./Transaction"));
2021-07-08 19:02:42 +00:00
const App = () => {
2021-07-09 05:07:20 +00:00
const runtime = useRuntime();
2021-07-08 19:02:42 +00:00
return (
<Suspense fallback={<>LOADING</>}>
2021-07-09 05:07:20 +00:00
<RuntimeContext.Provider value={runtime}>
2021-07-08 19:02:42 +00:00
<Router>
<Switch>
<Route path="/" exact>
<Home />
</Route>
<Route path="/search" exact>
<Search />
</Route>
<Route>
<Title />
<Route path="/block/:blockNumberOrHash" exact>
<Block />
</Route>
<Route path="/block/:blockNumber/txs" exact>
<BlockTransactions />
</Route>
<Route path="/tx/:txhash">
<Transaction />
</Route>
<Route path="/address/:addressOrName/:direction?">
<AddressTransactions />
</Route>
</Route>
</Switch>
</Router>
2021-07-09 05:07:20 +00:00
</RuntimeContext.Provider>
2021-07-08 19:02:42 +00:00
</Suspense>
);
};
2021-07-01 18:21:40 +00:00
export default React.memo(App);