Skip to content

Commit c0d151d

Browse files
committed
Only call findDOMNode if necessary
1 parent 28e8e92 commit c0d151d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Transition.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class Transition extends React.Component {
216216
if (nextStatus !== null) {
217217
// nextStatus will always be ENTERING or EXITING.
218218
this.cancelNextCallback()
219-
const node = ReactDOM.findDOMNode(this)
219+
const node = this.needsNode() ? ReactDOM.findDOMNode(this) : null;
220220

221221
if (nextStatus === ENTERING) {
222222
this.performEnter(node, mounting)
@@ -334,6 +334,19 @@ class Transition extends React.Component {
334334
}
335335
}
336336

337+
needsNode() {
338+
return [
339+
'addEndListener',
340+
'onEnter',
341+
'onEntering',
342+
'onEntered',
343+
'onExit'
344+
].some(callbackName => {
345+
const callback = this.props[callbackName];
346+
return callback && callback.length > 0
347+
})
348+
}
349+
337350
render() {
338351
const status = this.state.status
339352
if (status === UNMOUNTED) {

0 commit comments

Comments
 (0)