The title is clickbait and React.Fragment (<></>) has very valid use cases. The example you showed technically doesn't need to return a fragment—you can just do return !isEmpty && (...). Or just return null if it's empty, depending on what your preference is.
There are other valid use cases for fragments, too, like if you need to return two siblings but without introducing unnecessary wrapper parents.
My apologies if you feel the title is clickbait. That wasn't my intention at all.
My article wants to point out that we should use the tools provided by frameworks and libraries in the scope of our domain solution. Returning React.Fragment as an empty list is something valid and will work but it doesn't mean nothing if we, as programmers, don't give it a meaning. Everything depends on requirements and, maybe, we don't need to deep dive in a big file structure with lots of components because it increase complexity.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The title is clickbait and React.Fragment (
<></>
) has very valid use cases. The example you showed technically doesn't need to return a fragment—you can just doreturn !isEmpty && (...)
. Or just return null if it's empty, depending on what your preference is.There are other valid use cases for fragments, too, like if you need to return two siblings but without introducing unnecessary wrapper parents.
My apologies if you feel the title is clickbait. That wasn't my intention at all.
My article wants to point out that we should use the tools provided by frameworks and libraries in the scope of our domain solution. Returning
React.Fragment
as an empty list is something valid and will work but it doesn't mean nothing if we, as programmers, don't give it a meaning. Everything depends on requirements and, maybe, we don't need to deep dive in a big file structure with lots of components because it increase complexity.