dillon1000/react
Commit
Browse files 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.Changed paths2 files
First-parent comparisonsrc/addons/transitions/ReactTransitionGroup.js ModifiedM src/addons/transitions/__tests__/ReactTransitionGroup-test.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…