DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for React: Neatly hide conditional DOM elements πŸ‘€
Matt Shirlaw
Matt Shirlaw

Posted on

React: Neatly hide conditional DOM elements πŸ‘€

If you are anything like me you always cringe a little bit when you come across something like this in a React project 😬

Without react conditional block

The more conditionals that you have, the worse it gets and the as people add more and more code over time it just gets worse and worse.

To solve this I always end up building a tiny wrapper component to hide this logic away. I'm sure other people do this sort of thing as well so I built a little npm package which will let you do this

With react conditional block

If you are interested you can get it on NPM. It certainly won't save you a heap of time but hey, a minute saved is a minute saved right 😜

Latest comments (0)

Become a Moderator Can you help us make DEV a better place?

Fill out this survey and help us by becoming a tag moderator here at DEV.