I'm trying to render the React-Semantic UI Message and based on the condition I need to display Content or list based on the condition.
Working code:
const Message = ({icon, header, content, className, list}) => {
if(Array.isArray(content))
{
return (
<SemanticMessage
icon={icon}
header={header}
className={className}
list={content}
/>
)
} else {
return (
<SemanticMessage
icon={icon}
header={header}
className={className}
content={content}
/>
)
}
}
But this is not working:
const Message = ({icon, header, content, className, list}) => {
return (
<Message
icon={icon}
header={header}
className={className}
{...Array.isArray(content) ? [list={content}] : [content={content}]}
/>
)
}
any leads? what I am missing here?