Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Accordion Header Component Using Context
const AccordionHeader = (props) => {
return (
<AccordionItemContext.Consumer>
{({ expanded, toggleExpansion }) => (
<h2 className="accordion-header">
<button onClick={toggleExpansion}>
{ expanded ? '' : '' }
{ props.children }
</button>
</h2>
)}
</AccordionItemContext.Consumer>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.