Skip to content

Commit 18d267f

Browse files
committed
Updated to use refs rather than findNode as it's deprecated and was crashing in my usage.
1 parent 2eb45b2 commit 18d267f

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"./lib/dist/react-transition-group.js": {
3-
"bundled": 80859,
4-
"minified": 22686,
5-
"gzipped": 6939
3+
"bundled": 82017,
4+
"minified": 22806,
5+
"gzipped": 7001
66
},
77
"./lib/dist/react-transition-group.min.js": {
8-
"bundled": 46875,
9-
"minified": 15056,
10-
"gzipped": 4715
8+
"bundled": 47393,
9+
"minified": 15176,
10+
"gzipped": 4768
1111
}
1212
}

src/Transition.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as PropTypes from 'prop-types'
22
import React from 'react'
3-
import ReactDOM from 'react-dom'
43
import { polyfill } from 'react-lifecycles-compat'
54

65
import { timeoutsShape } from './utils/PropTypes'
@@ -140,6 +139,10 @@ class Transition extends React.Component {
140139
this.nextCallback = null
141140
}
142141

142+
setChildNode = node => {
143+
this.childNode = node
144+
}
145+
143146
getChildContext() {
144147
return { transitionGroup: null } // allows for nested Transitions
145148
}
@@ -216,12 +219,13 @@ class Transition extends React.Component {
216219
if (nextStatus !== null) {
217220
// nextStatus will always be ENTERING or EXITING.
218221
this.cancelNextCallback()
219-
const node = ReactDOM.findDOMNode(this)
220-
221-
if (nextStatus === ENTERING) {
222-
this.performEnter(node, mounting)
223-
} else {
224-
this.performExit(node)
222+
const node = this.childNode
223+
if (node) {
224+
if (nextStatus === ENTERING) {
225+
this.performEnter(node, mounting)
226+
} else {
227+
this.performExit(node)
228+
}
225229
}
226230
} else if (this.props.unmountOnExit && this.state.status === EXITED) {
227231
this.setState({ status: UNMOUNTED })
@@ -357,6 +361,8 @@ class Transition extends React.Component {
357361
delete childProps.onExiting
358362
delete childProps.onExited
359363

364+
childProps.ref = this.setChildNode
365+
360366
if (typeof children === 'function') {
361367
return children(status, childProps)
362368
}

0 commit comments

Comments
 (0)