Javascript: react/jsx-no-bind: arrow functions and garbage collection

Created on 13 Apr 2016  路  2Comments  路  Source: airbnb/javascript

I saw that you are allowing arrow functions with jsx-no-bind again. Part of the reasoning was that bind is slow while creation of arrow functions is not. The explanation on the eslint page only talks about garbage collection ("This is bad for performance, as it will result in the garbage collector being invoked way more than is necessary." - https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md). At first glance these seem to be two different types of reasons (speed of function creation vs. performance hit due to garbage collection intervals), but maybe I'm missing something?

question react

Most helpful comment

thanks a lot, @ljharb

All 2 comments

.bind is particularly slow, much much slower than creating new functions.

Creating new functions may indeed cause the GC to be invoked more often, and this should be a performance consideration when one gets to that point - but since performance should be considered last (and only after detailed profiling of clean, tested, and working code), a style guide shouldn't generally be concerned with performance where readability is otherwise a concern.

thanks a lot, @ljharb

Was this page helpful?
0 / 5 - 0 ratings

Related issues

graingert picture graingert  路  3Comments

felixsanz picture felixsanz  路  3Comments

stephenkingsley picture stephenkingsley  路  3Comments

surfaceowl picture surfaceowl  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments