https://nkbt.github.io/react-copy-to-clipboard/
npm install react-copy-to-clipboard
const initState = {value: '', copied: false}
function App() {
const [state, setState] = useState(initState);
cosnt onCopy = () => {
setState({copied: true});
};
const onClick = ({target: {innerHTML}}) => {
console.log(`Clicked on "${innerHTML}"!`);
};
return (
<CopyToClipboard
onCopy={onCopy}
options={{message: 'Whoa!'}}
text={state.value}
>
<button onClick={onClick}>Copy to clipboard with onClick prop</button>
</CopyToClipboard>
)
}