Skip to content
Snippets Groups Projects
Verified Commit b4ee6740 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Replace with this hook since cookie request is unique.

parent bd8fbef1
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!45Polished auth flow including ReservedRoute and role selection.
import React, { FC, useContext, useEffect, useState } from 'react'; import React, { FC, useCallback, useContext, useState } from 'react';
import axios from 'axios'; import axios from 'axios';
import { SubmitHandler, useForm } from 'react-hook-form'; import { SubmitHandler, useForm } from 'react-hook-form';
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
...@@ -20,7 +20,7 @@ export const SignInForm: FC = () => { ...@@ -20,7 +20,7 @@ export const SignInForm: FC = () => {
const { setRole, setIsAuth } = useContext(AuthContext); const { setRole, setIsAuth } = useContext(AuthContext);
const [cookie, setCookie] = useState<string>(''); const [cookie, setCookie] = useState<string>('');
useEffect(() => { useCallback(() => {
let isMounted = true; let isMounted = true;
if (isMounted) if (isMounted)
fetchCookie().then((cookieResponse) => setCookie(cookieResponse)); fetchCookie().then((cookieResponse) => setCookie(cookieResponse));
...@@ -28,7 +28,7 @@ export const SignInForm: FC = () => { ...@@ -28,7 +28,7 @@ export const SignInForm: FC = () => {
return () => { return () => {
isMounted = false; isMounted = false;
}; };
}, []); }, [cookie]);
const { control, errors, setError, handleSubmit } = useForm<CredentialsType>({ const { control, errors, setError, handleSubmit } = useForm<CredentialsType>({
defaultValues, defaultValues,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment