Skip to content

Allow jsx-no-bind to ignore dom components #1238

@otakustay

Description

@otakustay

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:

  1. If we are using a custom component in above code, we can pass name and selected to component's props and call this.props.onClick(this.props.name, this.props.selected) to prevent such function bindings, however we cannot do this with DOM components
  2. DOM components are never PureComponent, so a large reason for jsx-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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions