Revert "Test loading user from localstorage on first render"

This reverts commit 701d0a06cd.
This commit is contained in:
James Grugett 2022-10-02 14:16:54 -05:00
parent 747977556b
commit 0fb263efa4

View File

@ -58,9 +58,14 @@ export function AuthProvider(props: {
serverUser?: AuthUser
}) {
const { children, serverUser } = props
const [authUser, setAuthUser] = useStateCheckEquality<AuthUser>(
serverUser ?? getStoredUser()
)
const [authUser, setAuthUser] = useStateCheckEquality<AuthUser>(serverUser)
useEffect(() => {
if (serverUser === undefined) {
const cachedUser = localStorage.getItem(CACHED_USER_KEY)
setAuthUser(cachedUser && JSON.parse(cachedUser))
}
}, [setAuthUser, serverUser])
useEffect(() => {
if (authUser != null) {
@ -129,10 +134,3 @@ export function AuthProvider(props: {
<AuthContext.Provider value={authUser}>{children}</AuthContext.Provider>
)
}
const getStoredUser = () => {
if (typeof window === 'undefined') return undefined
const json = localStorage.getItem(CACHED_USER_KEY)
return json ? JSON.parse(json) : undefined
}