Closed
Description
When a rerender requires the last child to be moved to first place, the update to the DOM is not minimal. Instead of removing the child in question and re-inserting it, all the other children are removed and re-added instead.
This is bad for two reasons:
- It is unnecessary churn on the DOM, slowing things down. If any of the children is or contains a video element, the video will reset.
- Using keys to shuffle children around is pretty common when implementing an infinite scroll in React with DOM element reuse. This should work.
Here's a screencast showing how the DOM is changed while I scroll. Notice how when I scroll down the first element is correctly removed from the top and inserted at the bottom. When I scroll back up, instead of moving the last element, React moves the other four.
https://dl.dropboxusercontent.com/u/140702/ReactDomOperations.mov
I'm using React 0.9.0.
Metadata
Metadata
Assignees
Labels
No labels