title: How to know "children" prop component type in a functional component?
body: <p>I want to assign props dynamically in the children of a component</p>
  <p>Ex: I want to check if the component passed in children here is of type Second, and in that case, add a &quot;prova&quot; prop</p>
  <pre class="lang-js prettyprint-override"><code>export const First: React.FC&lt;PropsWithChildren&lt;{}&gt;&gt; = ({ children }) =&gt; {
      const modifiedChildren = useMemo(
          () =&gt;
              React.Children.map(children, (child) =&gt; {
          if (React.isValidElement(child)) {
            if(child.type === 'Second')
                      return React.cloneElement(child, { ...child.props, prova: &quot;ciao&quot; });
                  }
              }),
          [children]
      );
      return &lt;&gt;{modifiedChildren}&lt;/&gt;;
  };
  </code></pre>
  <p>The &quot;type&quot; property on the child doesnt seem to return the name as it does in Class components (as from what I've seen in other people examples), how am I supposed to do this the correct way ?</p>
  <pre class="lang-js prettyprint-override"><code>
  // main
  export const MainPage = () =&gt; {
      return (
          &lt;First&gt;
              &lt;Second&gt;&lt;/Second&gt;
          &lt;/First&gt;
      );
  };
  
  // second
  export const Second: React.FC&lt;{ prova?: string }&gt; = ({ prova }) =&gt; {
      return &lt;div&gt;{prova}&lt;/div&gt;;
  };
  
  </code></pre>