1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00

Store userData in localStorage

This commit is contained in:
Steffo 2021-09-19 16:03:15 +02:00
parent ad6b4c423e
commit 3854e75a23
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -4,6 +4,7 @@ import {useInstance, useInstanceAxios} from "./InstanceContext";
import {useNotNullContext} from "../hooks/useNotNullContext"; import {useNotNullContext} from "../hooks/useNotNullContext";
import {Validity} from "@steffo/bluelib-react/dist/types"; import {Validity} from "@steffo/bluelib-react/dist/types";
import {useFormState} from "@steffo/bluelib-react"; import {useFormState} from "@steffo/bluelib-react";
import {useStorageState} from "../hooks/useStorageState";
export interface UserData { export interface UserData {
@ -32,7 +33,7 @@ interface LoginContextProps {
export function LoginContextProvider({children}: LoginContextProps): JSX.Element { export function LoginContextProvider({children}: LoginContextProps): JSX.Element {
const api = useInstanceAxios() const api = useInstanceAxios()
const [userData, setUserData] = React.useState<UserData | null>(null) const [userData, setUserData] = useStorageState<UserData | null>(localStorage, "userData", null)
const [running, setRunning] = React.useState<boolean>(false) const [running, setRunning] = React.useState<boolean>(false)
const login = React.useCallback( const login = React.useCallback(