// @flow // $FlowIssue import React, { useState } from 'react'; import dynamic from 'next/dynamic'; import * as Styled from './style'; import Icon from '../Icon'; import type { ButtonProps } from './types'; const Clipboard = dynamic(() => import('react-clipboard.js'), { ssr: false, loading: () => null, }); 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} ); }