4 ms·
I just avoid most of it by moving the complex conditional logic into a separate component and rendering that. I don't think I've run into many issues with this
by TameAntelope 5y ago
I just avoid most of it by moving the complex conditional logic into a separate component and rendering that.
I don't think I've run into many issues with this strategy, and keeps my return statements nice and clean.
- matt-attack 5y agoI find ternaries alone to be totally adequate.
- TameAntelope 5y agoOh they work, but stacking them tends to make future reading of the code harder due to their increased complexity.
- kingdomcome50 5y agoNested 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).
- vlunkr 5y agoAgreed, if it's more complex than a single ternary, or && statements, make a new component.