javascript - Call a 'Fathers' function form a 'Children' componen in ReactJS -


i have next component 'father' contains 'children' component in react js.

var father = react.createclass({     render: function () {         return (             <div>                 <children/>             </div>         );     },     onupdate: function(state) {         this.setstate(state);     } }); 

i want call onupdate function on father children without calling 'children' method 'componentdidupdate' because i'm using method other thing breaks application.

how can that.

pass down in properties. if need update specific parts , prevent children updating, use method shouldcomponentupdate

var father = react.createclass({   render: function () {     return (         <div>             <children onupdatecallback={this.onupdate}/>         </div>     );   },   onupdate: function(state) {     this.setstate(state);   } });  var child = react.createclass({   render: function () { ... },    shouldcomponentupdate: function (prevprops, prevstate) { ... return false} }); 

if children can't/shouldn't update while parent does, think doing wrong, luck.


Popular posts from this blog

html/hta mutiple file in audio player -

debugging - Reference - What does this error mean in PHP? -