Re:JavaScript fundamentals before learning React
by minitech on Friday July 20, 2018 @02:32AM
(#17572941)
> How can I do this without defining a function?
You do define a function, but only once. Constructor:
this.smth = this.smth.bind(this);
JSX:
<button onClick={this.smth}></button>
Kind of awkward, but the standard practice last I checked. Arrow methods (terminology?) are also something you can add to the language that does the equivalent of .bind() replacements.
You do define a function, but only once. Constructor:
JSX: Kind of awkward, but the standard practice last I checked. Arrow methods (terminology?) are also something you can add to the language that does the equivalent of .bind() replacements.