DEV Community

Discussion on: A Clean Way to Conditionally Render Components

Collapse
 
igor_bykov profile image
Igor Bykov • Edited

Just out of curiosity: do you really think that evaluation of a control-flow-like one-liner might turn into a bottleneck in a react app?

I mean, I'm agree that this approach might be error prone if one works with deeply nested & all-levels fully optional objects/arrays (which isn't the most common use case in the world by the way) but do you think it may anyhow affect the rendering performance?

I mean, it seems unlikely that someone would just accidentially stitch in all DOOM engine logic re-written & adapted for JS in-between the <If></If>, isn't it?

Collapse
 
loucyx profile image
Lou Cyx • Edited

You don't have to take my word for this (even when I did this in the past, realized it was a mistake and stopped doing it), you can just google this "If" component approach. I'm not the only one that knows this isn't ideal because you're evaluating branches of logic even when you aren't actually going into them.