javascript - React his.setState is not a function -
this parent element :
changeddata(){ this.setstate({ changed: true }).bind(this) } i'm passing child:
<aboutme changeddata={this.changeddata} auth={this.props.auth} profile={profile}/> the child:
datachanged(data) { this.props.changeddata(); console.log("datachanged!!") }
make sure bind this before calling within function. can either change changeddata function signature es6 arrow function auto bind it:
changeddata = () => { } or can bind in child component this:
<aboutme changeddata={this.changeddata.bind(this)} auth={this.props.auth} profile={profile}/>
Comments
Post a Comment