title: pass forwardRef via cloneElement reactjs
body: <pre><code>const ref = useRef()  
  
   React.Children.map(this.props.children, (element) =&gt; {
     React.cloneElement(element, { 
       innerRef: node =&gt; ref,
     })
   })
  </code></pre>
  
  <p>here element is a component</p>
  
  <p>like the following</p>
  
  <pre><code>const newComponent = forwardRef(({children, ...otherprops}, ref){
      return (
       &lt;div {...otherprops} ref={otherprops.innerRef}&gt;
         {children}
       &lt;/div&gt;
      )        
  })
  </code></pre>
  
  <p>getting <code>ref</code> is <code>null</code> in forwardRef...</p>
  
  <p>Reproducible example :- <a href="https://codesandbox.io/s/forward-ref-cloneelement-1msjp" rel="noreferrer">https://codesandbox.io/s/forward-ref-cloneelement-1msjp</a></p>