react typescript image resizing and download

I was implement image resize and image download. But I see an error in 73line..

I see an reference, but I can't solve the problem...

1 answer

  • answered 2022-05-04 11:22 marius florescu

    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 = () => {
          const card = cardRef.current;
          domtoimage.toBlob(card).then((blob) => {
            saveAs(blob, "card.png");

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum