UNPKG

component-library-react

Version:
18 lines (15 loc) 420 B
import { useState } from "react"; export default function AccordionItem({ name = "accordionItem", HeadSection = () => <p>Hello!</p>, MainSection = () => <p>This is the main text!</p>, handleClick = () => {}, }) { const [open, setOpen] = useState(false); return ( <div id={name} onClick={() => handleClick([open, setOpen])}> <HeadSection /> {open ? <MainSection /> : null} </div> ); }