Moved frontend to separate folder, added basic user context and user page
This commit is contained in:
26
front/context/user/index.tsx
Normal file
26
front/context/user/index.tsx
Normal file
@ -0,0 +1,26 @@
|
||||
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 UserProvider: React.FC = ({ children }) => {
|
||||
const [state, setState] = useState<UserT>(initialContext);
|
||||
|
||||
const value = useMemo(() => ({ userState: state, setUserState: setState }), [
|
||||
state,
|
||||
]);
|
||||
|
||||
return <UserContext.Provider value={value}>{children}</UserContext.Provider>;
|
||||
};
|
||||
|
||||
export { UserProvider, UserContext };
|
||||
|
||||
export type { UserT, UserContextT } from "../../types/userContext";
|
Reference in New Issue
Block a user