← BYTES
React.js·Intermediate·Ref: 4.2.11

What's the practical tradeoff between wrapping sibling elements in a `<div>` versus a `<React.Fragment>` (`<>...</>`)?

Have a question about this video? Mention reference 4.2.11 when you contact us.

a.There is no difference whatsoever in any case
b.`<div>` is always faster to render than a Fragment
c.Fragments can only be used in class components
d.A `<div>` adds an actual extra node to the rendered DOM (which can affect CSS layout like flex/grid), while a Fragment groups elements with no extra DOM node at all
Because a Fragment produces no real DOM element, it's the right choice when you need to satisfy JSX's "one root element" requirement but don't want an extra wrapping node that could interfere with CSS layout (e.g. breaking a parent's flex or grid children assumptions).

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES4211#Reactjs