-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Allow jsx-no-bind to ignore dom components #1238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
The rule is for when you render anything that might be a PureComponent; not if the component in question is one. When you need to pass a function to an event handler that varies on props/state, you should only use a constructor-bound instance method. I do agree that ignoring DOM components in this rule makes perfect sense, though (as an option). |
alexzherdev
added a commit
to alexzherdev/eslint-plugin-react
that referenced
this issue
Jun 30, 2018
alexzherdev
added a commit
to alexzherdev/eslint-plugin-react
that referenced
this issue
Jun 30, 2018
alexzherdev
added a commit
to alexzherdev/eslint-plugin-react
that referenced
this issue
Jun 30, 2018
ljharb
pushed a commit
to alexzherdev/eslint-plugin-react
that referenced
this issue
Jun 30, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my point of view the
jsx-no-bind
rule is mostly forPureComponent
, although there is consideration on GC performance, it should not be significantIn many cases, we need to pass some arguments to an event handler, for example:
This will trigger the
jsx-no-bind
rule, here we have 2 concerns: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 componentsPureComponent
, so a large reason forjsx-no-bind
rule will not be a benefit for DOM componentsFor these reasons, I expect the
jsx-no-bind
can have aignoreDOMComponents
config to ignore function bindings on DOM componentsThe text was updated successfully, but these errors were encountered: