React.Fragment
only groups elements without adding an extra node to the DOM.
But I noticed these elements are just added to the immediate parent as children, or if the parent already has some children, then these elements are added as the "later" siblings of the existing children.
Its the developer's decision on where the element will render, a counterexample:
<div>
<>
<div>Hello</div>
<div>World</div>
</>
<div>Other</div>
</div>
// Results
<div>
<div>Hello</div>
<div>World</div>
<div>Other</div>
</div>
Or as components:
const App = () => {
return (
<div>
<ComponentUsingFragment />
<div>Other</div>
</div>
);
};
const ComponentUsingFragment = () => {
return (
<>
<div>Hello</div>
<div>World</div>
</>
);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…