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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -