Hi currently have the following code React code:
return (
<Container>
{booleanValueOne ? (
<TrueComponent props={props} />
) : (
[
<DefaultComponentOne props={props} />,
<DefaultComponentTwo props={props} />,
]
)}
</Container>
);
So if booleanValueOne is true we return <TrueComponent and if not returning an array of DefaultComponents. This is straightforward.
But I since want to add a second boolean value: booleanValueTwo - and if it's true, return TrueComponentTwo & if neither of booleanValueOne or booleanValueTwo are true, returning the array of default components.
Can anyone share best practises for doing so?
I can't use a ternary as I have 3 possible outcomes.
if - else if - else:)if return? No need forelse<Container>{(() => {})()}</Container>