nkbt / react-copy-to-clipboard

Copy-to-clipboard React component
MIT License
2.33k stars 123 forks source link

Add hook 'useClipboard' for use on reusable component and easily to use it #182

Closed thinnakrit closed 2 years ago

thinnakrit commented 2 years ago
import {useClipboard} from 'react-copy-to-clipboard';

const CopyButton = () => {
  const [isCopy, setClipboard] = useClipboard()
  const onClickButton = () => {
    setClipboard('Copy Text Example')
  }

  return (
    <div>
      {isCopy && <span>Copied!</span>}
      <button onClick={onClickButton}>Submit</button>
    </div>
  )
}

setClipboard: PropTypes.func isCopy: PropTypes.booleen