Skip to content

Commit

Permalink
fix: make sure to only dispatch if it was not already loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarde committed Dec 12, 2023
1 parent ed8cf11 commit 1c44b11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/FormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ const FormView = ({
const userId = useSelector((state) =>
state.userSession.token ? jwtDecode(state.userSession.token).sub : '',
);
const isUserLoaded = useSelector((state) => state.users?.get?.loaded);
const curUserEmail = useSelector(
(state) => state.users?.user?.email || false,
);
const dispatch = useDispatch();
useEffect(() => {
if (userId?.length > 0 && curUserEmail === false) dispatch(getUser(userId));
if (userId?.length > 0 && !isUserLoaded) dispatch(getUser(userId));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [userId]);

Expand Down

0 comments on commit 1c44b11

Please sign in to comment.