Skip to content

feat(Transition): Only call findDOMNode if necessary #468

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ after_success:
branches:
only:
- master
- strict
17 changes: 15 additions & 2 deletions src/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Transition extends React.Component {
if (nextStatus !== null) {
// nextStatus will always be ENTERING or EXITING.
this.cancelNextCallback()
const node = ReactDOM.findDOMNode(this)
const node = this.needsNode() ? ReactDOM.findDOMNode(this) : null;

if (nextStatus === ENTERING) {
this.performEnter(node, mounting)
Expand Down Expand Up @@ -313,7 +313,7 @@ class Transition extends React.Component {
this.setNextCallback(handler)

const doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener
if (!node || doesNotHaveTimeoutOrListener) {
if (doesNotHaveTimeoutOrListener) {
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

setTimeout(this.nextCallback, 0)
return
}
Expand All @@ -327,6 +327,19 @@ class Transition extends React.Component {
}
}

needsNode() {
return [
'addEndListener',
'onEnter',
'onEntering',
'onEntered',
'onExit'
].some(callbackName => {
const callback = this.props[callbackName];
return callback && callback.length > 0
})
}

render() {
const status = this.state.status
if (status === UNMOUNTED) {
Expand Down