File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change @@ -20,16 +20,6 @@ import { nameShape } from './utils/PropTypes'
20
20
const reactCSSTransitionReplaceChild = React . createFactory ( ReactCSSTransitionReplaceChild )
21
21
22
22
23
- // Filter out nulls before looking for an only child
24
- function getChildMapping ( children ) {
25
- if ( ! Array . isArray ( children ) ) {
26
- return children
27
- }
28
- const childArray = React . Children . toArray ( children ) . filter ( c => c )
29
- return childArray . length === 1 ? childArray [ 0 ] : React . Children . only ( childArray )
30
- }
31
-
32
-
33
23
export default class ReactCSSTransitionReplace extends React . Component {
34
24
35
25
static displayName = 'ReactCSSTransitionReplace'
@@ -64,7 +54,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
64
54
65
55
this . state = {
66
56
currentKey : '1' ,
67
- currentChild : getChildMapping ( this . props . children ) ,
57
+ currentChild : this . props . children ? React . Children . only ( this . props . children ) : undefined ,
68
58
prevChildren : { } ,
69
59
height : null ,
70
60
}
@@ -87,7 +77,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
87
77
}
88
78
89
79
componentWillReceiveProps ( nextProps ) {
90
- const nextChild = getChildMapping ( nextProps . children )
80
+ const nextChild = nextProps . children ? React . Children . only ( nextProps . children ) : undefined
91
81
const { currentChild} = this . state
92
82
93
83
if ( ( ! currentChild && ! nextChild ) || ( currentChild && nextChild && currentChild . key === nextChild . key ) ) {
You can’t perform that action at this time.
0 commit comments