Interesting! I think the only time I've used an approach like that is when using something like react-responsive and their MediaQuery component, which is basically the same idea. But for code I control, I can't say I've ever reached for this technique.
What are your thoughts? Do you like this pattern better than explicitly using ternaries or && operators?
I think it is neat way to handle conditional rendering that is OK to use for simpler cases only.
I found parts of the app that had that utility component stacked one on top of the other with various different conditions and it felt bizarre and too hacky.
I used it only recently in the code base that already had it. In all other projects I am more comfortable with using && and ternaries as I find them easier to read and understand what is going on, also feels more natural to me.
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.
Interesting! I think the only time I've used an approach like that is when using something like react-responsive and their
MediaQuery
component, which is basically the same idea. But for code I control, I can't say I've ever reached for this technique.What are your thoughts? Do you like this pattern better than explicitly using ternaries or
&&
operators?I think it is neat way to handle conditional rendering that is OK to use for simpler cases only.
I found parts of the app that had that utility component stacked one on top of the other with various different conditions and it felt bizarre and too hacky.
I used it only recently in the code base that already had it. In all other projects I am more comfortable with using
&&
and ternaries as I find them easier to read and understand what is going on, also feels more natural to me.