I was implement image resize and image download. But I see an error in 73line..
https://codesandbox.io/s/serene-monad-sc6imu?file=/src/App.tsx
I see an reference, but I can't solve the problem...
CodePudding user response:
To solve your issue, change the declaration of the cardRef
to:
const cardRef = useRef<HTMLDivElement | null>(null);
You should also remove the casting (const card = cardRef.current as any;
) and modify it as follows:
const onDownloadBtn = () => {
if(cardRef.current){
const card = cardRef.current;
domtoimage.toBlob(card).then((blob) => {
saveAs(blob, "card.png");
});
}
};