DEV Community 👩‍💻👨‍💻

DEV Community 👩‍💻👨‍💻 is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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 😜

Top comments (0)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!