Skip to content

Commit

Permalink
fix useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
peterphanouvong committed May 19, 2022
1 parent a9e85e6 commit e466324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/frontend/AuthProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ export default ({ children, initialUser }) => {
}, [profileUrl]);

// if you get the user set loading false
useEffect(async () => {
if (state.user) return;
await checkSession();
setState((previous) => ({ ...previous, isLoading: false }));
useEffect(() => {
const checkLoading = async () => {
await checkSession();
setState((previous) => ({ ...previous, isLoading: false }));
};
if (!state.user) {
checkLoading();
}
}, [state.user]);

// provide this stuff to the rest of your app
Expand Down

0 comments on commit e466324

Please sign in to comment.