File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,9 @@ export default class ReactCSSTransitionReplace extends React.Component {
101
101
const nextChild = nextProps . children ? React . Children . only ( nextProps . children ) : false
102
102
const currentChild = this . state . currentChild
103
103
104
- if ( currentChild && nextChild && nextChild . key === currentChild . key ) {
104
+ // Avoid silencing the transition when this.state.nextChild exists because it means that there’s
105
+ // already a transition ongoing that has to be replaced.
106
+ if ( currentChild && nextChild && nextChild . key === currentChild . key && ! this . state . nextChild ) {
105
107
// Nothing changed, but we are re-rendering so update the currentChild.
106
108
return this . setState ( {
107
109
currentChild : nextChild ,
@@ -117,9 +119,10 @@ export default class ReactCSSTransitionReplace extends React.Component {
117
119
118
120
const { state } = this
119
121
120
- // When transitionLeave is set to false, it might happen that current component is not yet
121
- // rendered when a new component reaches this part of the code. At this point we want to
122
- // use the height and width of the latest rendered elment.
122
+ // When transitionLeave is set to false, refs.curr does not exist when refs.next is being
123
+ // transitioned into existence. When another child is set for this component at the point
124
+ // where only refs.next exists, we want to use the width/height of refs.next instead of
125
+ // refs.curr.
123
126
const ref = this . refs . curr || this . refs . next
124
127
125
128
// Set the next child to start the transition, and set the current height.
You can’t perform that action at this time.
0 commit comments