DEV Community

Discussion on: Working with conditions & lists in React

Collapse
 
chibiblasphem profile image
Debove Christopher

What do you advise to use then ? Ternary is expression and inside jsx expressions are the only way to do condition

Btw don't tell me to create a function which do the condition, that's really dirty. Well coded the use of ternary does not turn your code a mess.

Note that this is only my opinion

Collapse
 
sergiodxa profile image
Sergio Daniel Xalambrí

I think if you reach the point of having a lot of ternaries or too much nested ternaries, maybe, that component should be split in multiple components because the original one becomes too complex.

But most of the time ternaries are not a problem IMO and you can use them without issues, most probably before you reach the point ternaries are a problem you have another problem and already split the component.