Closed
Description
In terms of performance, is there any difference between using arrow functions and bind manually when using es6 classes? Using arrow functions the methods are not on the class prototype, it will be on the class instance only. Using bind will attach the methods to class prototype. It sounds like bind manually will have better performance, does that mean we should consider using bind instead of arrow functions for class methods?
Any suggestions or comments are really appreciated!
So in terms of performance, would you recommend using
class MyComponent extends React.Component {
constructor(props) {
super(props)
}
methodA = () => { ... }
}
or
class MyComponent extends React.Component {
constructor(props) {
super(props)
this.methodA = this.methodA.bind(this)
}
methodA() { ... }
}
Metadata
Metadata
Assignees
Labels
No labels