// @flow import React, { useRef, useState } from 'react'; import classnames from 'classnames'; import Button from 'component/button'; import { useRect } from '@reach/rect'; const COLLAPSED_HEIGHT = 120; type Props = { children: React$Node | Array, }; export default function Expandable(props: Props) { const [expanded, setExpanded] = useState(false); const { children } = props; const ref = useRef(); const rect = useRect(ref); function handleClick() { setExpanded(!expanded); } return (
{rect && rect.height > COLLAPSED_HEIGHT ? (
{children}
) : (
{children}
)}
); }