From 1c44b11df132d63ea90f46e212b14625601a4501 Mon Sep 17 00:00:00 2001 From: Matthias Barde Date: Tue, 12 Dec 2023 11:53:56 +0100 Subject: [PATCH] fix: make sure to only dispatch if it was not already loaded --- src/components/FormView.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/FormView.jsx b/src/components/FormView.jsx index 7d001b7..663a13f 100644 --- a/src/components/FormView.jsx +++ b/src/components/FormView.jsx @@ -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]);