Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 476 Bytes

jsx-no-useless-fragment.md

File metadata and controls

21 lines (15 loc) · 476 Bytes

Pattern: Unnecessary Fragment usage

Issue: -

Description

React Fragments are useful for grouping multiple children without adding extra DOM nodes. However, when a fragment contains only a single child element, string, or expression, it becomes unnecessary and should be removed to reduce code complexity.

Examples

Example of incorrect code:

<>foo</>
<div><>foo</></div>

Example of correct code:

<>foo <div></div></>
<div>foo</div>