Suppose the component below is instantiated a thousand times (I'm not talking about one instantiation being re-rendered a thousand times):
class TableRow extends Component {
render() {
return (
<tr onClick={() => {console.log('You clicked this table row!');}}>
<td>foo</td>
<td>bar</td>
</tr>
);
}
}
If the onClick function is only created when actual click happens, then I'll stop worrying. But if it's created a thousand times, I'll want to move it into the prototype, which is going to be ugly.
(I know if I put it into the class field, like handleClick = {console.log('You clicked this table row!)}
, it'll definitely be slow, because it's compiled into the constructor. But is the inline pattern any faster?)