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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -