diff --git a/hooks/useUser.js b/hooks/useUser.js index 7e5952bb..2bc81569 100644 --- a/hooks/useUser.js +++ b/hooks/useUser.js @@ -59,9 +59,9 @@ export const UserProvider = ({ children }) => { // new one if needed useEffect(() => { const interval = setInterval(() => { - const tokenCreatedAt = JSON.parse( - localStorage.getItem('bearer'), - )?.created_at + const tokenCreatedAt = localStorage + ? JSON.parse(localStorage.getItem('bearer'))?.created_at + : null // if localStorage is disabled in the browser it returns null if (tokenCreatedAt) { const tokenExpiry = tokenCreatedAt + TWELVE_HOURS const now = Date.now() @@ -118,8 +118,4 @@ export const UserProvider = ({ children }) => { ) } -const useUser = () => { - return useContext(UserContext) -} - export default useUser