1import { useCopyToClipboard } from 'react-modern-hooks'23const Demo = () => {4 const { copiedText, copyText, error, copied } = useCopyToClipboard()56 console.log('is text copied', copied)78 return (9 <div>10 {error ? <p>Error copying text: {error}</p> : null}1112 <button onClick={() => copyText('Copy this text to clipboard')}>13 Copy Text to clipboard14 </button>15 </div>16 )17}1819export default Demo
No input variables
error - Error message that occured during copy
copied - Boolean state if the text was copied successfully
copiedText - The copied text
copyText - A function to copy the text