import { useEffect,useRef } from "react"; import createTextImage, { TextImageOptions } from "./createTextImage"; export default function useCreateTextImage( text: string, textColor: string, backgroundColor: string | false, options: TextImageOptions = {} ) { const imageRef = useRef(null); useEffect(() => { if (imageRef.current) { const image = createTextImage(text, textColor, backgroundColor, options); imageRef.current.src = image.src; } // Cleanup function to remove image ref return () => { if (imageRef.current) { imageRef.current.src = ''; } }; }, [text, textColor, backgroundColor, options]); return imageRef; }