|
1 | 1 | import * as PropTypes from 'prop-types'
|
2 | 2 | import React from 'react'
|
3 |
| -import ReactDOM from 'react-dom' |
4 | 3 | import { polyfill } from 'react-lifecycles-compat'
|
5 | 4 |
|
6 | 5 | import { timeoutsShape } from './utils/PropTypes'
|
@@ -140,6 +139,10 @@ class Transition extends React.Component {
|
140 | 139 | this.nextCallback = null
|
141 | 140 | }
|
142 | 141 |
|
| 142 | + setChildNode = node => { |
| 143 | + this.childNode = node |
| 144 | + } |
| 145 | + |
143 | 146 | getChildContext() {
|
144 | 147 | return { transitionGroup: null } // allows for nested Transitions
|
145 | 148 | }
|
@@ -216,12 +219,13 @@ class Transition extends React.Component {
|
216 | 219 | if (nextStatus !== null) {
|
217 | 220 | // nextStatus will always be ENTERING or EXITING.
|
218 | 221 | 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 | + } |
225 | 229 | }
|
226 | 230 | } else if (this.props.unmountOnExit && this.state.status === EXITED) {
|
227 | 231 | this.setState({ status: UNMOUNTED })
|
@@ -357,6 +361,8 @@ class Transition extends React.Component {
|
357 | 361 | delete childProps.onExiting
|
358 | 362 | delete childProps.onExited
|
359 | 363 |
|
| 364 | + childProps.ref = this.setChildNode |
| 365 | + |
360 | 366 | if (typeof children === 'function') {
|
361 | 367 | return children(status, childProps)
|
362 | 368 | }
|
|
0 commit comments