npm.io
2.0.1 • Published 6 years ago

@react-hook/copy

Licence
MIT
Version
2.0.1
Deps
0
Size
21 kB
Vulns
0
Weekly
0
Stars
1.5K

useCopy()

Bundlephobia Types NPM Version MIT License

npm i @react-hook/copy

A React hook for copying text to the clipboard

Quick Start

import useCopy from '@react-hook/copy'

const Component = (props) => {
  const {copied, copy, reset} = useCopy(
    'This text will be copied to the clipboard'
  )

  return <a onClick={copy}>{copied === false ? 'Copy' : 'Copied'}</a>
}

API

useCopy(text: string)
Argument Type Required? Description
text string Yes The text you want to copy to the clipboard when copy is clicked
Returns {copied: boolean, copy: () => void, reset: () => void}

LICENSE

MIT

Keywords