-
Notifications
You must be signed in to change notification settings - Fork 50.3k
Description
Similar to #2296.
I would love to tell a REACT component : "I don't care in what order you render the elements, just minimize the DOM operations and maintain the elements by key"
In effect: whenever a re-render happens React removes the elements that are no longer there. And new elements are appended to the end. The order is never accounted for.
While ES6 Sets may not be available in many browsers, I would love a similar feature implemented with Objects now.
Explanation:
Right now, when passing an array of children with keys as property, their order is preserved. This is usually the correct behavior.
However, I have projects where I'm using the trick from famo.us to render elements using transform: translate values instead. In this case, all elements have position; absolute; top: 0; left: 0; anyway and their actual order on the DOM does not matter.
The major benefit is that with this trick, it eliminates almost all DOM operations (except updating styles) and any page reflow or paints for great performance.
The problem is that with React maintaining the order of the children, React, reorders the DOM elements anyway.
There are ways where I have to keep track of every render and manually reorder the data to prevent re-renders, but there has got to be a better way.