> Yes, using a ternary operator in JSX to conditionally render components/values looks a bit ugly, but nothing is stopping you from making a wrapper component like:
Couldn't you put that in a function that returns the correct JSX element or am I misunderstanding the problem? Something like:
You have to be careful with code like the above in React. Using a lower-cased function that returns JSX but is not rendered with react.createElement (either directly or via the JSX syntax) can lead to confusing violations of the rules of hooks as it relates to exact ordering of calls.
This is because it doesn't get registered as it's own component, so conditionally called children with hooks may cause errors.
Couldn't you put that in a function that returns the correct JSX element or am I misunderstanding the problem? Something like:
Simple ternaries are fine IMO but thats what I do when the logic gets complicated. I never used a nested ternary in that situation, for example.