Files
zkldi_Tachi/client/src/context/BackgroundContext.tsx
T
2021-07-20 17:59:55 +01:00

21 lines
639 B
TypeScript

import React, { createContext, useState } from "react";
import { JustChildren, SetState } from "types/react";
import { NO_OP } from "util/misc";
export const BackgroundContext = createContext<{
background: string | null;
setBackground: SetState<string | null>;
}>({ background: null, setBackground: NO_OP });
BackgroundContext.displayName = "BackgroundContext";
export function BackgroundContextProvider({ children }: JustChildren) {
const [background, setBackground] = useState<string | null>(null);
return (
<BackgroundContext.Provider value={{ background, setBackground }}>
{children}
</BackgroundContext.Provider>
);
}