Is there any way I can store inside header base on section.type different titles like <p> {section.title1} </p> or <p> {section.title2} </p> ?
return (
<Collapse
onToggle={onHandleClick}
header={
<p> {section.title1} </p>
}
</Collapse>
);
CodePudding user response:
Yes, you can do it in this way:
header={
<p> {section.type ? section.title1 : section.title2} </p>
}
CodePudding user response:
You can a do a conditional render:
return (
<Collapse
onToggle={onHandleClick}
header={
section.type ? <p>{section.title1}</p> : <p>{section.title2}</p>
}
</Collapse>
)
