0

there is this thread that I tought it was my solution. Basically what I want to do is to send multiple function inside one that is sent over an onClick callback. The console returns an error saying that my functions inside wrapper function are not defined.

This is my code:

function1(){ this.setState({ ... }); } function2(){ ... } mainFunction(e){ function1(); function2(); } <Component2 clickHandler={this.mainFunction}/> 

I also bind the functions in my constructor method just in case. When I fire the event clicking in my second component i get return that function1 is not defined. Any ideas?

4
  • It should be this.function1();. function1 is a property of the function, not a binding at is in scope. Commented May 30, 2017 at 14:08
  • Yes it worked thank you very much! Commented May 30, 2017 at 14:32
  • I meant to say "property of the object". Commented May 30, 2017 at 14:35
  • Can you posted as an answer in order to marked as accepted answer please Commented May 30, 2017 at 14:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.