component-library-react
Version:
A library of ready to use components for React
18 lines (15 loc) • 420 B
JSX
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>
);
}