DEV Community

Discussion on: A React "if component"

Collapse
 
josdejong profile image
Jos de Jong • Edited

I do like this solution. We've used this in the past but reverted this again soon: it led to performance issues.

Unlike the ternary operator a ? b : c or &&, this <IF>...</IF> component will always create and render its inner contents (children), and in case the condition is false, the rendered children is only ignored by <IF> in the end. That can be very expensive.