plane/space/lib/mobx/store-init.tsx

19 lines
426 B
TypeScript
Raw Normal View History

import { useEffect } from "react";
// js cookie
import Cookie from "js-cookie";
// mobx store
2024-03-19 14:38:35 +00:00
import { useMobxStore } from "@/lib/mobx/store-provider";
const MobxStoreInit = () => {
const { user: userStore } = useMobxStore();
useEffect(() => {
const authToken = Cookie.get("accessToken") || null;
if (authToken) userStore.fetchCurrentUser();
}, [userStore]);
return <></>;
};
export default MobxStoreInit;