jsx-eslint/eslint-plugin-react

react/jsx-no-useless-fragment false positive

Open

#2.584 geöffnet am 3. März 2020

Auf GitHub ansehen
 (15 Kommentare) (23 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
help wanted

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

There's a false positive on the rule with forwarded children. Use cases are pretty rare but still exist. Without a fragment around the children, code breaks at runtime

const HollowComponent = ({ children }) => {
  // some logic here
  return <>{children}</>; // doesn't pass the rule
}

example: https://codesandbox.io/s/icy-lake-ri3uo

Temporary fix is to disable rule for this line but it would be nicer if this rule let this kind of Fragment use possible.

Contributor Guide