mirror of
https://github.com/exogen/t2-model-skinner.git
synced 2026-02-25 09:33:40 +00:00
17 lines
484 B
TypeScript
17 lines
484 B
TypeScript
import React, { useContext } from "react";
|
|
|
|
interface ImageLoaderContextValue {
|
|
loadImage: (url: string) => Promise<ArrayBuffer>;
|
|
}
|
|
|
|
export const ImageLoaderContext =
|
|
React.createContext<ImageLoaderContextValue | null>(null);
|
|
ImageLoaderContext.displayName = "ImageLoaderContext";
|
|
|
|
export default function useImageLoader() {
|
|
const context = useContext(ImageLoaderContext);
|
|
if (!context) {
|
|
throw new Error("ImageLoaderContext.Provider not found!");
|
|
}
|
|
return context;
|
|
}
|