title: React add new props to cloned element with spread operator
body: <p>I have a container like so:</p>
  
  <pre><code>const ReactContainer = ({ children, ...rest }) =&gt; React.cloneElement(children, rest);
  </code></pre>
  
  <p>Now, I want to add new props - <code>count</code> and <code>flag</code> - to the cloned elements:</p>
  
  <p>So I tried this:</p>
  
  <pre><code>const ReactContainer = ({ children, ...rest }) =&gt; {
      const count = 0;
      const flag = false;
  
      return React.cloneElement(children, {count, flag}, rest);
  };
  </code></pre>
  
  <p>But this doesn't work and I've tried other variations. How can I add these new props to the cloned elements keeping the spread operator for simplicity?</p>