-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove debatable statement on perf in jsx-no-bind #2067
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, i think this is a good change. Nobody should be thinking about memory management in a memory managed language anyways :-)
@@ -1,6 +1,6 @@ | |||
# No `.bind()` or Arrow Functions in JSX Props (react/jsx-no-bind) | |||
|
|||
A `bind` call or [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) in a JSX prop will create a brand new function on every single render. This is bad for performance, as it will result in the garbage collector being invoked way more than is necessary. It may also cause unnecessary re-renders if a brand new function is passed as a prop to a component that uses reference equality check on the prop to determine if it should update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s a minor performance issue that applies only to functions, which is that the same function object isn’t optimized until it’s been called multiple times - so if you create a new one on every render, you’re resetting the progress on optimizing that function.
Thanks @ljharb! |
Overview
The PR removes a controversial and debatable line that is the source of much confusion
See: