diff --git a/src/context/auth.js b/src/context/auth.js index e5c46b5..e263d89 100644 --- a/src/context/auth.js +++ b/src/context/auth.js @@ -29,12 +29,11 @@ function AuthProvider(props) { async function bootstrapUser() { const user = window.localStorage.getItem('$USER'); if (user) { - console.log(user); setState({ status: 'success', user: JSON.parse(user), error: null }); } } bootstrapUser(); - }, [setState]); + }, []); const login = (email, password) => { setState({ ...state, status: 'pending' }); @@ -51,10 +50,8 @@ function AuthProvider(props) { }; const logout = () => { - setState({ ...state, status: 'pending' }); - return getUser().then(() => - setState({ status: 'success', user: null, error: null }) - ); + setState({ status: 'success', user: null, error: null }); + window.localStorage.clear(); }; return ; diff --git a/src/screens/Home/index.js b/src/screens/Home/index.js index cf56389..190a837 100644 --- a/src/screens/Home/index.js +++ b/src/screens/Home/index.js @@ -1,12 +1,15 @@ +import { useAuthState } from '../../context/auth'; import { useUser } from '../../context/user'; function Home() { const { isPending, classrooms } = useUser(); + const { logout } = useAuthState(); return (

Página inicial

+ {isPending &&

Loading...

}
);