import { AxiosError } from "axios"; import React, { Dispatch, ReactNode, SetStateAction, createContext, useState, } from "react"; type AppContextType = { // data: AxiosResponse<{}, any> | undefined; data: AppState; isLoading: boolean; error: AxiosError | undefined; setAppState: Dispatch>; // mutate: KeyedMutator>; swrKey: string | false | Record; }; // const initialState = { // isLoading: true, // } as const; export const AppContext = createContext({} as AppContextType); type AppState = { isJoined?: boolean; clanName?: string; }; interface AppContextProviderProps { children: ReactNode; } export const WithAppState = (props: AppContextProviderProps) => { const { children } = props; const { isLoading, error, swrKey } = { isLoading: false, error: undefined, swrKey: "default", }; const [data, setAppState] = useState({ isJoined: false }); return ( {children} ); }; export const useAppState = () => React.useContext(AppContext);