SyntaxFix
Write A Post
Hire A Developer
Questions
There are a couple of ways.
One is to add this.onToggleLoop = this.onToggleLoop.bind(this); in the constructor.
this.onToggleLoop = this.onToggleLoop.bind(this);
Another is arrow functions onToggleLoop = (event) => {...}.
onToggleLoop = (event) => {...}
And then there is onClick={this.onToggleLoop.bind(this)}.
onClick={this.onToggleLoop.bind(this)}