React.Fragment looks like DocumentFragment. But does React.Fragment
has the same performance benefits like DocumentFragment
?
In other words, are this
// index.jsx
const arr = [...Array.from({length: 10000})];
return (
<ul>
<>
{arr.map((x, i) => <li>{i}</li>)}
</>
</ul>
)
and this
// index.js
const arr = [...Array.from({length: 10000})];
const fragment = new DocumentFragment();
for(let i = 0; i < arr.length; ++i) {
const li = document.createElement('li');
li.textContent = i;
fragment.append(li);
}
document.querySelector('ul').append(fragment)
the same?
Or I still should use DocumentFragment
for large data like below?
//index.jsx
const arr = [...Array.from({length: 10000})];
const fragment = new DocumentFragment();
for(let i = 0; i < arr.length; ++i) {
const li = document.createElement('li');
li.textContent = i;
fragment.append(li);
}
return (
<ul>
{fragment}
</ul>
)