Skip to content

Commit 02bee87

Browse files
committed
Only call findDOMNode if necessary
1 parent 87832e9 commit 02bee87

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
@@ -222,7 +222,7 @@ class Transition extends React.Component {
222222
if (nextStatus !== null) {
223223
// nextStatus will always be ENTERING or EXITING.
224224
this.cancelNextCallback()
225-
const node = ReactDOM.findDOMNode(this)
225+
const node = this.needsNode() ? ReactDOM.findDOMNode(this) : null;
226226

227227
if (nextStatus === ENTERING) {
228228
this.performEnter(node, mounting)
@@ -340,6 +340,19 @@ class Transition extends React.Component {
340340
}
341341
}
342342

343+
needsNode() {
344+
return [
345+
'addEndListener',
346+
'onEnter',
347+
'onEntering',
348+
'onEntered',
349+
'onExit'
350+
].some(callbackName => {
351+
const callback = this.props[callbackName];
352+
return callback && callback.length > 0
353+
})
354+
}
355+
343356
render() {
344357
const status = this.state.status
345358
if (status === UNMOUNTED) {

0 commit comments

Comments
 (0)