import { useState } from 'react'; import PropTypes from 'prop-types'; import { Button } from 'react-basics'; import { FormattedMessage } from 'react-intl'; const defaultText = ( ); function CopyButton({ element, ...props }) { const [text, setText] = useState(defaultText); function handleClick() { if (element?.current) { element.current.select(); document.execCommand('copy'); setText(); window.getSelection().removeAllRanges(); } } return ( ); } CopyButton.propTypes = { element: PropTypes.shape({ current: PropTypes.shape({ select: PropTypes.func.isRequired, }), }), }; export default CopyButton;