javascript - pass {...this.state} with {this.props.children} -
hi , time.
i see tutorial lynda.com react.js. but, used old version of react. code:
render: function(){ return ( <div> <header title={this.state.title} status={this.state.status}/> <routehandler {...this.state} /> </div> ) }
but use new version of react 15.2.1 , react-router 2.5.2. , don't know how pass {...this.state} {this.props.children}
render: function(){ return ( <div> <header title={this.state.title} status={this.state.status}/> {this.props.children} </div> ) }
thank you, everyone
in order pass props {this.props.children}
, can use react.cloneelement.the resulting element have original element's props new props merged in shallowly.
render: function(){ return ( <div> <header title={this.state.title} status={this.state.status}/> {react.cloneelement(this.props.children,this.state)} </div> ) }
Comments
Post a Comment