-
Notifications
You must be signed in to change notification settings - Fork 651
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
feat(Transition): Only call findDOMNode if necessary #468
Conversation
@@ -326,7 +326,7 @@ class Transition extends React.Component { | |||
this.setNextCallback(handler) | |||
|
|||
const doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener | |||
if (!node || doesNotHaveTimeoutOrListener) { | |||
if (doesNotHaveTimeoutOrListener) { |
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.
Has its own commit (87832e9). No test broke upon removing this so I need some guidance to understand this condition.
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 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.
That PR did not introduce the evaluation of node
.
this is cool, the problem nowdays with this approach tho is destructuring messings with the observable arity of the function e.g. function foo(...args) {
console.log(args
}
foo.length // 0 |
It was to good to be true. This would be a breaking change then at which point we might as well remove the call completely.
Any thoughts about #468 (comment)? |
02bee87
to
c0d151d
Compare
Cherry-picking reactjs#468 ## Breaking Callbacks that use argument spread or access `arguments` will not have acces to the DOM node. The DOM node is only passed if Function.prototype.length is greater than 0. ``` // no node passed const noNodeCallback = () => {}; // node passed const withNodeCallback = node => {}; ``` The first callback enables strict mode compatible usage of `Transition`. If you expect the node in callbacks a call to `findDOMNode` is required which issues a warning in `React.StrictMode`.
405fac0
to
9e41fc1
Compare
Fixed with #559 |
Another approach to #457. It only calls findDOMNode if any of the callbacks has the node argument specified.
This is only exploratory since seemingly unrelated implementation had to be change. Details at the affected line.