dillon1000/react

Commit

Fix ReactTransitionGroup behavior when removing several children at once

If several children complete leaving before rendering TransitionGroup,
only the last one was removed. This could easily happen if
callback in componentWillLeave is called synchronously and several items
are removed from array. The other case is when ReactCSSTransitionGroup
has transitionLeave={false} and array is also cleaned up.

The bug was happening because this.state.children was used as a base for
children removal and it wasn't updated until the render, so only the last
removal was actually happening.

Fix involves keeping the updated children state between invocations of
_handleDoneLeaving. After updating this.state and rendering,
updatedState is cleaned up and ready for subsequent array modifications.

Test case included.
Browse files
Changed paths2 files
First-parent comparison
M src/addons/transitions/ReactTransitionGroup.js ModifiedM src/addons/transitions/__tests__/ReactTransitionGroup-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…