// @flow // $FlowIssue import React, { useState } from 'react'; import { CopyLinkButton as StyledCopyLinkButton } from './style'; import Icon from '../Icon'; import type { ButtonProps } from './types'; type CopyLinkProps = { ...$Exact, text: string, }; export default function CopyLinkButton(props: CopyLinkProps) { const { text, children } = props; const [isClicked, handleClick] = useState(false); const onClick = () => { handleClick(true); setTimeout(() => handleClick(false), 2000); }; return ( {isClicked ? 'Copied!' : children} ); }