Layout improvements, some additions
This commit is contained in:
22
front/context/loading.tsx
Normal file
22
front/context/loading.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import React, { Dispatch, SetStateAction, useMemo, useState } from "react";
|
||||
|
||||
const LoadingContext = React.createContext<LoadingContextT>(null);
|
||||
|
||||
type LoadingContextT = {
|
||||
loading: boolean;
|
||||
setLoading: Dispatch<SetStateAction<boolean>>;
|
||||
};
|
||||
|
||||
const LoadingProvider: React.FC = ({ children }) => {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
|
||||
const value = useMemo<LoadingContextT>(() => ({ loading, setLoading }), [
|
||||
loading,
|
||||
]);
|
||||
|
||||
return (
|
||||
<LoadingContext.Provider value={value}>{children}</LoadingContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export { LoadingContext, LoadingProvider };
|
15
front/context/ref.tsx
Normal file
15
front/context/ref.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import React, { MutableRefObject, useRef } from "react";
|
||||
|
||||
const HomeRefContext = React.createContext<MutableRefObject<HTMLDivElement>>(
|
||||
null
|
||||
);
|
||||
|
||||
const HomeRefProvider: React.FC = ({ children }) => {
|
||||
const value = useRef<HTMLDivElement>(null);
|
||||
|
||||
return (
|
||||
<HomeRefContext.Provider value={value}>{children}</HomeRefContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export { HomeRefContext, HomeRefProvider };
|
@ -2,17 +2,10 @@ import React, { useMemo, useState } from "react";
|
||||
|
||||
import { UserContextT, UserT } from "types/userContext";
|
||||
|
||||
const UserContext = React.createContext<UserContextT>(null);
|
||||
|
||||
const initialContext: UserT = {
|
||||
username: "",
|
||||
email: "",
|
||||
points: 0,
|
||||
id: 0,
|
||||
};
|
||||
const UserContext = React.createContext<UserContextT | null>(null);
|
||||
|
||||
const UserProvider: React.FC = ({ children }) => {
|
||||
const [state, setState] = useState<UserT>(initialContext);
|
||||
const [state, setState] = useState<UserT>();
|
||||
|
||||
const value = useMemo(() => ({ userState: state, setUserState: setState }), [
|
||||
state,
|
||||
|
Reference in New Issue
Block a user