> 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:
renderThing(number) {
if(number > 0) return <div>...</div>
return <div>...</div>
}
const Page = () => {
return <div>{renderThing(someNumber)}</div>
}
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.