import React, { useCallback, useState } from 'react' import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap' import PropTypes from 'prop-types' import { Trans } from 'react-i18next' import Icon from './icon' export default function CopyLink({ link, tooltipId }) { const [copied, setCopied] = useState(false) const handleClick = useCallback(() => { navigator.clipboard.writeText(link).then(() => { setCopied(true) window.setTimeout(() => { setCopied(false) }, 1500) }) }, [link]) if (!navigator.clipboard?.writeText) { return null } return ( {copied ? 'Copied!' : } } > ) } CopyLink.propTypes = { link: PropTypes.string.isRequired, tooltipId: PropTypes.string.isRequired, }