Skip to content

Commit

Permalink
fix: unable to login
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Aug 24, 2023
1 parent 4d23817 commit f0ace4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/layouts/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -47,7 +48,7 @@ export const RootLayout: FC = () => {
</div>
</Tooltip>
<div className="flex-1" />
<AccountButton />
{token && <AccountButton />}
</Toolbar>
</AppBar>
<Container maxWidth="lg" className="pt-16">
Expand Down
4 changes: 3 additions & 1 deletion src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const LOCALSTORAGE_KEYS = {
}

export const useToken = () => {
return useLocalStorage(LOCALSTORAGE_KEYS.TOKEN)
return useLocalStorage<string>(LOCALSTORAGE_KEYS.TOKEN, undefined, {
raw: true,
})
}

export const getToken = () => {
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ export default defineConfig(({ mode }) => ({
disable: mode !== "production",
}),
],
build: {
sourcemap: true,
},
}))

0 comments on commit f0ace4f

Please sign in to comment.