From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src/core/hooks/useAuth.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/core/hooks/useAuth.js (limited to 'src/core/hooks/useAuth.js') diff --git a/src/core/hooks/useAuth.js b/src/core/hooks/useAuth.js new file mode 100644 index 00000000..488562f6 --- /dev/null +++ b/src/core/hooks/useAuth.js @@ -0,0 +1,14 @@ +import { getAuth } from "../utils/auth" + +const useAuth = () => { + const [auth, setAuth] = useState(null) + + useEffect(() => { + const handleIsAuthenticated = () => setAuth(getAuth()) + handleIsAuthenticated() + }, []) + + return [auth, setAuth] +} + +export default useAuth \ No newline at end of file -- cgit v1.2.3 From ed950b23d50f9b3993cfd2ac2386a5b3a68d5e57 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 20 Feb 2023 17:03:28 +0700 Subject: fix --- src/core/hooks/useAuth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hooks/useAuth.js') diff --git a/src/core/hooks/useAuth.js b/src/core/hooks/useAuth.js index 488562f6..13f04454 100644 --- a/src/core/hooks/useAuth.js +++ b/src/core/hooks/useAuth.js @@ -1,3 +1,4 @@ +import { useEffect, useState } from "react" import { getAuth } from "../utils/auth" const useAuth = () => { @@ -8,7 +9,7 @@ const useAuth = () => { handleIsAuthenticated() }, []) - return [auth, setAuth] + return auth } export default useAuth \ No newline at end of file -- cgit v1.2.3 From f66b12fd1d0b83af0d7230d7b1565fbe00afbe3c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Feb 2023 11:03:34 +0700 Subject: prettier --- src/core/hooks/useAuth.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/hooks/useAuth.js') diff --git a/src/core/hooks/useAuth.js b/src/core/hooks/useAuth.js index 13f04454..af62e45c 100644 --- a/src/core/hooks/useAuth.js +++ b/src/core/hooks/useAuth.js @@ -1,5 +1,5 @@ -import { useEffect, useState } from "react" -import { getAuth } from "../utils/auth" +import { useEffect, useState } from 'react' +import { getAuth } from '../utils/auth' const useAuth = () => { const [auth, setAuth] = useState(null) @@ -12,4 +12,4 @@ const useAuth = () => { return auth } -export default useAuth \ No newline at end of file +export default useAuth -- cgit v1.2.3