Improve effect

There is no need to create function each time when history changes and do not use it.
This commit is contained in:
Denis Skiba
2020-02-01 12:10:43 +07:00
committed by GitHub
parent 190dfcd9dc
commit cb7710378d

View File

@@ -10,7 +10,8 @@ const Authenticate = () => {
const history = useHistory(); const history = useHistory();
useEffect(() => { useEffect(() => {
const createGuestAccount = async () => { if (!getStoredAuthToken()) {
const createGuestAccount = async () => {
try { try {
const { authToken } = await api.post('/authentication/guest'); const { authToken } = await api.post('/authentication/guest');
storeAuthToken(authToken); storeAuthToken(authToken);
@@ -19,8 +20,6 @@ const Authenticate = () => {
toast.error(error); toast.error(error);
} }
}; };
if (!getStoredAuthToken()) {
createGuestAccount(); createGuestAccount();
} }
}, [history]); }, [history]);