This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { ReactNode, useContext, useState } from "react"
|
||||
import { useEffect } from "react"
|
||||
import React, { ReactNode, useContext, useEffect, useState } from "react"
|
||||
import { useJwt } from "react-jwt";
|
||||
import { deleteToken, getToken, storeToken } from "../Utils";
|
||||
|
||||
@@ -16,7 +15,7 @@ type ContextProps = {
|
||||
|
||||
const authContext = React.createContext<AuthContextProps | null>(null);
|
||||
|
||||
export function ProvideAuth(props: ContextProps) {
|
||||
export function ProvideAuth(props: Readonly<ContextProps>) {
|
||||
const auth = useProvideAuth();
|
||||
return <authContext.Provider value={auth}>{props.children}</authContext.Provider>
|
||||
}
|
||||
@@ -29,7 +28,7 @@ function useProvideAuth(): AuthContextProps {
|
||||
const [loginName, setLoginName] = useState<string | undefined>();
|
||||
const [trusted, setTrusted] = useState<boolean | undefined>();
|
||||
const [token, setToken] = useState<string | undefined>(getToken());
|
||||
const { decodedToken } = useJwt(token || '');
|
||||
const { decodedToken } = useJwt(token ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
if (token && token.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user