DEV Community

Discussion on: Are you giving the proper sense to React.Fragment?

Collapse
willsmart profile image
willsmart

I'm confused 🤔
Do you mean to say you're a coder but don't do it professionally?
Like, if you were a professional programmer you wouldn't have returned a fragment (since they don't do that sort of thing) but would have just returned null and been done with it?

Anyway, I totally agree that to be effective as a coder you need to have all the tools in the toolkit at your disposal, and know the situations where they're useful.

To me, fragments' domain of usefulness is for encapsulating multiple elements, or unknown numbers of elements, as one return value. If I'm returning zero elements, I'll return null since that is what null means: a typed but missing value.