t2-model-skinner/src/useEnvironment.ts
2024-01-27 01:06:54 -08:00

26 lines
748 B
TypeScript

import React, { useContext } from "react";
interface EnvironmentContextValue {
selectedEnvironment: string | null;
setSelectedEnvironment: (selectedEnvironment: string | null) => void;
showEnvironment: boolean;
setShowEnvironment: (showEnvironment: boolean) => void;
exposure: number;
setExposure: (exposure: number) => void;
environmentImageUrl: string | null;
}
const EnvironmentContext = React.createContext<EnvironmentContextValue | null>(
null
);
EnvironmentContext.displayName = "EnvironmentContext";
export { EnvironmentContext };
export default function useEnvironment() {
const context = useContext(EnvironmentContext);
if (!context) {
throw new Error("No EnvironmentContext.Provider");
}
return context;
}