DEV Community

Discussion on: Stop returning NULL components

Collapse
 
codyseibert profile image
Cody Seibert

Do you happen to have benchmarks that show how much this really affects performance?

Collapse
 
ucvdesh profile image
Daniel Silva

That's why I said that may potencially affect performance of the apps. I mean, if you have something really small or something that won't be changing a lot in the short term, you won't notice it, but still is something to work on because it's not a good practice tho...

Collapse
 
ucvdesh profile image
Daniel Silva

Hmmm, don't actually have a documented benchmark. But I've been seeing this a lot through multiple projects I worked on, specially on forms.

But I think is a great idea to add benchmarks, thanks! I will do it for sure!

Collapse
 
codyseibert profile image
Cody Seibert • Edited

Just wondering. I’ve never returned null in my react apps. I always just do {myBoolean && MyComponent()}. I can’t insert carot symbols but you get the point.

Thread Thread
 
ucvdesh profile image
Daniel Silva

Exactly! This is a correct conditional render, because MyComponent does not render unless myBoolean is true