I would like to render a component out of two depending on a flag value. I was wondering if there is a way to do this in only one line?
I was thinking something like this: <(flag ? Comp1 : Comp2) att1={attValue} ... />
If there is not a way, is it possible to somehow add it as a feature in the future?
You can interpolate a React.createElement that alternates between the two components.
<>
{
React.createElement(flag? Comp1 : Comp2, { att1: attValue }, null)
}
</>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With