refactor: add inited state
This commit is contained in:
parent
971991e808
commit
cbfce62f95
|
@ -34,6 +34,8 @@ export type LumeContextType = {
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
setIsLoggedIn: (value: boolean) => void;
|
setIsLoggedIn: (value: boolean) => void;
|
||||||
lume: LumeObject;
|
lume: LumeObject;
|
||||||
|
inited: boolean;
|
||||||
|
setInited: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
ready: boolean;
|
ready: boolean;
|
||||||
setReady: React.Dispatch<React.SetStateAction<boolean>>;
|
setReady: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
};
|
};
|
||||||
|
@ -45,6 +47,7 @@ const LumeContext = createContext<LumeContextType | undefined>(undefined);
|
||||||
const LumeProvider = ({ children }) => {
|
const LumeProvider = ({ children }) => {
|
||||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||||
const [ready, setReady] = useState<boolean>(false);
|
const [ready, setReady] = useState<boolean>(false);
|
||||||
|
const [inited, setInited] = useState<boolean>(false);
|
||||||
const [lume, setLume] = useState<LumeObject>({ networks: [] });
|
const [lume, setLume] = useState<LumeObject>({ networks: [] });
|
||||||
const statusUnsubs = useRef(new Map());
|
const statusUnsubs = useRef(new Map());
|
||||||
const isMounted = useRef(true); // Use a ref to track mounting
|
const isMounted = useRef(true); // Use a ref to track mounting
|
||||||
|
@ -137,7 +140,15 @@ const LumeProvider = ({ children }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LumeContext.Provider
|
<LumeContext.Provider
|
||||||
value={{ lume, ready, setReady, isLoggedIn, setIsLoggedIn }}>
|
value={{
|
||||||
|
lume,
|
||||||
|
ready,
|
||||||
|
setReady,
|
||||||
|
isLoggedIn,
|
||||||
|
setIsLoggedIn,
|
||||||
|
inited,
|
||||||
|
setInited,
|
||||||
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</LumeContext.Provider>
|
</LumeContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue