From cb7710378de175c2e83ac84f9e71455c22ffb8f2 Mon Sep 17 00:00:00 2001 From: Denis Skiba Date: Sat, 1 Feb 2020 12:10:43 +0700 Subject: [PATCH] Improve effect There is no need to create function each time when history changes and do not use it. --- client/src/Auth/Authenticate.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/Auth/Authenticate.jsx b/client/src/Auth/Authenticate.jsx index cf22672..67ff7d0 100644 --- a/client/src/Auth/Authenticate.jsx +++ b/client/src/Auth/Authenticate.jsx @@ -10,7 +10,8 @@ const Authenticate = () => { const history = useHistory(); useEffect(() => { - const createGuestAccount = async () => { + if (!getStoredAuthToken()) { + const createGuestAccount = async () => { try { const { authToken } = await api.post('/authentication/guest'); storeAuthToken(authToken); @@ -19,8 +20,6 @@ const Authenticate = () => { toast.error(error); } }; - - if (!getStoredAuthToken()) { createGuestAccount(); } }, [history]);