A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Fixable: This rule is sometimes automatically fixable using the --fix
flag on the command line.
The following patterns are considered warnings:
<>{foo}</>
<><Foo /></>
<p><>foo</></p>
<></>
<Fragment>foo</Fragment>
<React.Fragment>foo</React.Fragment>
<section>
<>
<div />
<div />
</>
</section>
The following patterns are not considered warnings:
<>
<Foo />
<Bar />
</>
<>foo {bar}</>
<> {foo}</>
const cat = <>meow</>
<SomeComponent>
<>
<div />
<div />
</>
</SomeComponent>
<Fragment key={item.id}>{item.value}</Fragment>