Skip to content

Files

Latest commit

14d3467 · Jun 7, 2020

History

History
executable file
·
57 lines (44 loc) · 1.9 KB

README.md

File metadata and controls

executable file
·
57 lines (44 loc) · 1.9 KB

useCopy()

Bundlephobia Types Build status 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