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