From f0ace4f0f27a2968ebf73a8a377dd8bf3af2cc30 Mon Sep 17 00:00:00 2001 From: GalvinGao Date: Wed, 23 Aug 2023 22:27:21 -0400 Subject: [PATCH] fix: unable to login --- src/layouts/RootLayout.tsx | 5 +++-- src/utils/storage.ts | 4 +++- vite.config.ts | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/layouts/RootLayout.tsx b/src/layouts/RootLayout.tsx index 8150430..76a07c0 100644 --- a/src/layouts/RootLayout.tsx +++ b/src/layouts/RootLayout.tsx @@ -15,10 +15,11 @@ import { toast } from "react-hot-toast" import { graphql, useLazyLoadQuery } from "react-relay" import { Outlet, useNavigate } from "react-router-dom" import { useEffectOnce } from "react-use" -import { getToken, setToken } from "../utils/storage" +import { getToken, setToken, useToken } from "../utils/storage" import { RootLayoutQuery } from "./__generated__/RootLayoutQuery.graphql" export const RootLayout: FC = () => { + const [token] = useToken() const navigate = useNavigate() useEffectOnce(() => { const token = getToken() @@ -47,7 +48,7 @@ export const RootLayout: FC = () => {
- + {token && } diff --git a/src/utils/storage.ts b/src/utils/storage.ts index eca0d66..b6e284c 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -7,7 +7,9 @@ export const LOCALSTORAGE_KEYS = { } export const useToken = () => { - return useLocalStorage(LOCALSTORAGE_KEYS.TOKEN) + return useLocalStorage(LOCALSTORAGE_KEYS.TOKEN, undefined, { + raw: true, + }) } export const getToken = () => { diff --git a/vite.config.ts b/vite.config.ts index 492d01b..06b0738 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,4 +18,7 @@ export default defineConfig(({ mode }) => ({ disable: mode !== "production", }), ], + build: { + sourcemap: true, + }, }))