A React Fragment is a component that allows you to group multiple elements without adding an additional DOM node to the rendered output.
It helps to avoid unnecessary nesting when you need to return adjacent JSX elements from a component
The only attribute a Fragment can accept is the key prop. This is necessary when you are rendering a list of fragments in a loop. You must use the explicit <Fragment> syntax if you need to pass a key; the shorthand <>...</> does not support attributes.
You need to return two sibling <div> elements from a component without adding an extra wrapper element to the DOM. How would you do that using React?
If you accidentally wrap a list of items in a <div> instead of a fragment, what effect does that have on the rendered HTML and CSS layout?
Show me the JSX syntax for a fragment using both the shorthand and the long form.
We have a component that maps over an array and returns multiple rows, but we see a warning about keys. How would you use fragments to group each row's cells while still providing a key?
During a refactor, a colleague replaced a <section> wrapper with a fragment, and the page's CSS grid layout broke. Why might that happen?
If a fragment is used inside a <table> element, what constraints exist and how would you handle them?
Our UI library renders large lists with virtual scrolling. Discuss the trade‑offs of using fragments versus extra wrapper elements for each item in terms of performance and DOM size.
You need to expose a component's internal structure for testing but want to keep the DOM minimal in production. How could fragments help, and what pitfalls should you watch for at scale?
Explain how fragments interact with React's reconciliation algorithm when sibling elements are reordered.
We are planning a migration from a legacy codebase that heavily nests layout divs to a more semantic markup using fragments. What architectural considerations and tooling changes would you propose to ensure consistency across teams?
In a large monorepo, some teams use the shorthand <> syntax while others use <React.Fragment>. How would you enforce a standard and what impact does this have on TypeScript typings and linting?
If we introduce a custom Babel plugin that transforms fragments into a specific wrapper for analytics, what are the risks and how would you mitigate them?