Issue while appending a child to a div in react typescript

I am trying to add a image tag dynamically on a useref

   let myRef=useRef(null)
   useEffect(()=>{
   const newElement = document.createElement('image');
   myRef.current!.appendChild(newElement); 
  },[])

i am getting the following error and how i set height and width to the image while creating

Property 'appendChild' does not exist on type 'never'. TS2339



Read more here: https://stackoverflow.com/questions/67388993/issue-while-appending-a-child-to-a-div-in-react-typescript

Content Attribution

This content was originally published by Tej at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: