-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
In my point of view the jsx-no-bind
rule is mostly for PureComponent
, although there is consideration on GC performance, it should not be significant
In many cases, we need to pass some arguments to an event handler, for example:
<li key={name} className={className} onClick={() => this.onClickTag(name, selected)}>{text}</li>
This will trigger the jsx-no-bind
rule, here we have 2 concerns:
- If we are using a custom component in above code, we can pass
name
andselected
to component'sprops
and callthis.props.onClick(this.props.name, this.props.selected)
to prevent such function bindings, however we cannot do this with DOM components - DOM components are never
PureComponent
, so a large reason forjsx-no-bind
rule will not be a benefit for DOM components
For these reasons, I expect the jsx-no-bind
can have a ignoreDOMComponents
config to ignore function bindings on DOM components