Re:Advice on JSX Conditionals
by matt-attack on Wednesday March 09, 2022 @11:39AM
(#30616538)
I find ternaries alone to be totally adequate.
[ Parent
| on HN ]
Re:Advice on JSX Conditionals
by TameAntelope on Wednesday March 09, 2022 @12:10PM
(#30617043)
Oh they work, but stacking them tends to make future reading of the code harder due to their increased complexity.
Re:Advice on JSX Conditionals
by kingdomcome50 on Wednesday March 09, 2022 @12:18PM
(#30617179)
Nested ternaries can by structured to look a look like `if/else` if you put the `?/:` in the right spots.
It's a balance. Extracting logic into new components (and often new files!) isn't exactly ergonomic either.
I've found it's better to decrease readability if it makes understanding the logic more straight-forward (i.e. not hunting through several files to exhaust all possible outputs).