title: Child component function not called from parent in reactjs
body: <p>I am using reactjs to build a game. I have a parent component and I am trying to call a method in child component using ref but its not working. Can someone help why? (ignore case in below ex.)</p>
  <pre><code>function parent() {
      childRef = useRef()
  
      ...
      const someFunc = () =&gt; {
          childRef.current.childFunc()
      }
      ...
      return &lt;Child ref={childRef} /&gt;
  }
  
  function Child() {
      ...
      const childFunc = () =&gt; {
          ... code ...
      }
      ...
  }
  </code></pre>
  <p>Error: Cannot read property 'childFunc' of undefined</p>