revite/src/app.tsx

41 lines
1,013 B
TypeScript
Raw Normal View History

2021-06-18 15:07:26 -04:00
import { CheckAuth } from "./context/revoltjs/CheckAuth";
import { Route, Switch } from "react-router-dom";
import Context from "./context";
2021-06-18 15:21:54 -04:00
import { Login } from "./pages/login/Login";
import { useForceUpdate, useSelf, useUser } from "./context/revoltjs/hooks";
function Test() {
const ctx = useForceUpdate();
let self = useSelf(ctx);
let bree = useUser('01EZZJ98RM1YVB1FW9FG221CAN', ctx);
return (
<div>
<h1>logged in as { self?.username }</h1>
<h4>bree: { JSON.stringify(bree) }</h4>
</div>
)
}
2021-06-18 07:05:01 -04:00
export function App() {
2021-06-18 10:57:08 -04:00
return (
<Context>
2021-06-18 15:07:26 -04:00
<Switch>
<Route path="/login">
<CheckAuth>
2021-06-18 15:21:54 -04:00
<Login />
2021-06-18 15:07:26 -04:00
</CheckAuth>
</Route>
<Route path="/">
<CheckAuth auth>
<Test />
2021-06-18 15:07:26 -04:00
</CheckAuth>
</Route>
</Switch>
</Context>
2021-06-18 10:57:08 -04:00
);
2021-06-18 07:05:01 -04:00
}