Skip to content

Commit

Permalink
fix: 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seung365 committed Aug 7, 2024
1 parent 3814787 commit 9243816
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Provider/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { AuthContextType, AuthInfo } from '@/types';
import { Spinner } from '@chakra-ui/react';
import { createContext, useContext, useState, ReactNode, useEffect } from 'react';

export const AuthContext = createContext<AuthContextType | undefined>(undefined);

export const AuthProvider = ({ children }: { children: ReactNode }) => {
const [authInfo, setAuthInfo] = useState<AuthInfo | undefined>(undefined);
const [isReady, setIsReady] = useState(false);

const updateAuthInfo = (auth: AuthInfo) => {
if (auth) {
Expand All @@ -29,7 +31,10 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {

useEffect(() => {
handleAuthInfo();
});
setIsReady(true);
}, []);

if (!isReady) return <Spinner />;

return (
<AuthContext.Provider value={{ authInfo, updateAuthInfo }}>{children}</AuthContext.Provider>
Expand Down

0 comments on commit 9243816

Please sign in to comment.