-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I just wanted to do some conditional rendering of the child based on the heading level, and was surprised there wasn't some magic for me - so I used a State
I wonder if there's a better way, or if not, that it might be documented for future users :)
const [levelNumber, setLevelNumber] = useState(1);
return (
<Section
component={
<H
render={({ level, Component }) => (
setLevelNumber(level), (<Component className={`font-bold ${headingLevelClasses[level]} ${className}`}>{heading}</Component>)
)}
/>
}
>
{levelNumber == 1 && (
<div>
<HelpLink className="mr-2" helpUrl={helpUrl} />
</div>
)}
<div className="col-span-2">{children}</div>
</Section>
);
Metadata
Metadata
Assignees
Labels
No labels