mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-19 21:46:19 +00:00
34 lines
689 B
TypeScript
34 lines
689 B
TypeScript
import { useEffect, useState } from "react";
|
|
import { Outlet } from "react-router-dom";
|
|
import { globalService } from "./services";
|
|
import useUserStore from "./stores/v1/user";
|
|
|
|
function App() {
|
|
const userStore = useUserStore();
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const initialState = async () => {
|
|
try {
|
|
await globalService.initialState();
|
|
} catch (error) {
|
|
// do nothing
|
|
}
|
|
|
|
try {
|
|
await userStore.fetchCurrentUser();
|
|
} catch (error) {
|
|
// do nothing.
|
|
}
|
|
|
|
setLoading(false);
|
|
};
|
|
|
|
initialState();
|
|
}, []);
|
|
|
|
return <>{!loading && <Outlet />}</>;
|
|
}
|
|
|
|
export default App;
|