title: Unable to remove child from useRef hook
body: <p>I have the following <code>useRef</code> which contains 4 children.
  <br/>I am trying to remove a child from here based on an if check.</p>
  <p>But getting the error:</p>
  <pre><code>typeError: myRef.current.removeChild is not a function.
  </code></pre>
  <p>But looking at the answers here this seems to be correct. What am I doing wrong?</p>
  <p><a href="https://stackoverflow.com/questions/65425206/how-to-remove-the-child-element-of-a-div-in-react-using-useref-hook">How to remove the child element of a div in react using useRef hook?</a></p>
  <pre><code>//This is coming from another file. Just for reference. 
  const myRef = React.useRef();
  
  export const postData = (
    myRef,
    token,
    id1,
    id2,
  ) =&gt; {
    myRef.current.children[0].value = token;
    myRef.current.children[1].value = id1;
    myRef.current.children[2].value = id2;
  
    [...myRef.current.children].forEach((child) =&gt; {
      if (!child.value) {
  
        // error on this line 
        myRef.current.removeChild(child);
        
      }
    });
  };
  </code></pre>