Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

why is this undefined in react

There are a couple of ways to deal with it. see first stackoverflow answer you
will get it.

One is to add this.onToggleLoop = this.onToggleLoop.bind(this); in the constructor.

Another is arrow functions onToggleLoop = (event) => {...}.

And then there is onClick={this.onToggleLoop.bind(this)}.

 
PREVIOUS NEXT
Tagged: #undefined #react
ADD COMMENT
Topic
Name
3+1 =