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();
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]);