title: Pass function which sets child state as prop for this.props.children
body: <p>I need to pass <code>handleClose</code> as prop for <code>this.props.children</code>. This function must access to child state. I have a problem with <code>{handleClose: this.handleClose}</code> because I don't understand how to pass parameter <code>child</code> here. </p>
  
  <pre><code>class App extends React.Component {
      constructor(props, context) {
          super(props, context);
          this.handleClose = this.handleClose.bind(this);
      }
  
      handleClose(child) {
          if (child.state.redirect) {
              browserHistory.push(url);
          } else {
              child.setState({showError: false, errorText: ''});
          }
      }
  
      render() {
          const children = React.Children.map(this.props.children, (child) =&gt; {
              return React.cloneElement(child, 
                  {handleClose: this.handleClose}, this);
          });
  
          return (
              &lt;div&gt;
                  {children}
              &lt;/div&gt;
          );
      }
  }
  </code></pre>