2.0.1 • Published 4 years ago

@react-hook/copy v2.0.1

Weekly downloads
971
License
MIT
Repository
github
Last release
4 years ago

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)

ArgumentTypeRequired?Description
textstringYesThe text you want to copy to the clipboard when copy is clicked

Returns {copied: boolean, copy: () => void, reset: () => void}

LICENSE

MIT