Reputation: 63
I am not understanding why certain functions need the "= () =>" and other functions like 'onFirstDateRendered' don't have "= () =>" what's the difference between these 2 functions within a class based construct? thanks
onGridReady = (params) => {
this.gridApi = params.api
this.columnApi = params.columnApi
this.gridApi.sizeColumnsToFit()
}
onFirstDataRendered(params) {
params.api.sizeColumnsToFit()
}
Upvotes: 0
Views: 93
Reputation: 1075537
I'm guessing these are both within a class
construct. The first is a property declaration using an arrow function. The second is a method definition.
Sometimes people use the property-with-arrow-function form so that regardless of how the function is called, this
during the call will be the instance of the class that the property was created on; often these are event handlers. In constrast, with method definitions, the value of this
during the method call depends on the way the method is called.
Upvotes: 5