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

Set null when server not called.

parent b7ce3a82
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!51Fix/authorization
...@@ -8,11 +8,11 @@ import { useEffect, useState } from 'react'; ...@@ -8,11 +8,11 @@ import { useEffect, useState } from 'react';
* @returns {boolean | null} isAuth: true if user is authenticated, false otherwise or null if the request has not finished. * @returns {boolean | null} isAuth: true if user is authenticated, false otherwise or null if the request has not finished.
*/ */
export const useAuth = (): [ export const useAuth = (): [
boolean, boolean | null,
React.Dispatch<React.SetStateAction<boolean>>, React.Dispatch<React.SetStateAction<boolean | null>>,
] => { ] => {
let isMounted = true; let isMounted = true;
const [isAuth, setIsAuth] = useState<boolean>(false); const [isAuth, setIsAuth] = useState<boolean | null>(null);
useEffect(() => { useEffect(() => {
isAuthenticated().then((state) => { isAuthenticated().then((state) => {
if (isMounted) { if (isMounted) {
......
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