I much prefer this version:
return items && <ul> { items.map(i => <li key={i}>{i}</li>) } </ul>;
The logic is inlined so you don't have to jump between component when reading the code.
You won't have ever new dev on your team asking you why you are returning and empty fragment.
The final example looks more "clean", but what actually happens is that you have to jump around in the file a lot to understand what is happening.
Agree with your last point. We should balance the benefits of creating components and get a complex solution from a file structure point of view.
And we need to stop promoting ideas like DRY and Single Responsibility Principle, which are at best pointless and at worst harmful.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
I much prefer this version:
The logic is inlined so you don't have to jump between component when reading the code.
You won't have ever new dev on your team asking you why you are returning and empty fragment.
The final example looks more "clean", but what actually happens is that you have to jump around in the file a lot to understand what is happening.
Agree with your last point. We should balance the benefits of creating components and get a complex solution from a file structure point of view.
And we need to stop promoting ideas like DRY and Single Responsibility Principle, which are at best pointless and at worst harmful.