-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Closed
Labels
Description
There seems to be several schools regarding the way to write conditional JSX. React's documentation suggests ternary expressions or functions, there are packages using using conditional tags, such as jsx-control-statement.
I settled with ternary when there's not too much logic or when the components are not too big (I then fallback to functions), but ternary expressions can easily get hard to read, and the syntax/spacing really differs, a lot. You can find things without any () around elements, or with weird indentation, to things like that, which readable, feel a bit verbose:
this.props.condition === 'blah' ? (
<span>IfBlock</span>
) : (
<span>ElseBlock</span>
)
Do you folks have an opinion on that?
neil-rubens, nicknish, oshalygin, isaacalves and DmitryEfimenko