0

I have a function:

beginFunction: function(){
//does stuff
}

that I call inside componentDidMount(){this.beginFunction();}

inside beginFunction I call a function with promises and inside the .then I call other functions. one of the functions is this.retrieveMatches(); this.retrieveMatches(); calls another function this.makeHTMLtable and inside that function I have this line: msgButton.addEventListener("click", this.messageUser(), false);

When I refresh the page, the code inside this.messageUser(){console.log('hello')} get runs before I click the button. How can I change my react code so that it only gets called on click (I though that is what an addEventListener would do??

The worm
  • 5,580
  • 14
  • 36
  • 49

0 Answers0