javascript - "Don't set props of the React component" warning -


i'm getting react.js error i'd love know how fix it. there way call react.cloneelement on this?

warning: don't set .props.children of react component . instead, specify correct value when creating element or use react.cloneelement make new element updated props. element created seven.

here's full working example.

here's code:

var thead = react.createclass({   displayname: 'thead',   proptypes: function () {     return {       children: react.proptypes.node     }   },   componentwillmount: function () {     this.childtr = containselement('tr', this.props.children)     this.props.children = reconcilechildren('th',       (this.childtr) ? this.childtr.props.children : this.props.children,       this.props.data     )   },   render: function () {     return (       <thead>         {this.childtr ? <tr {...this.childtr.props}>           {this.props.children}         </tr> : <tr>           {this.props.children}         </tr>}       </thead>     )   } }) 

as @fuyushimoya said in comments discouraged alter props (which didn't know) set children this.children instead.

var thead = react.createclass({   displayname: 'thead',   proptypes: function () {     return {       children: react.proptypes.node     }   },   componentwillmount: function () {     this.childtr = containselement('tr', this.props.children)     this.children = reconcilechildren('th',       (this.childtr) ? this.childtr.props.children : this.props.children,       this.props.data     )   },   render: function () {     return (       <thead>         {this.childtr ? <tr {...this.childtr.props}>           {this.children}         </tr> : <tr>           {this.children}         </tr>}       </thead>     )   } }) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -