Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Latest commit

 

History

History

useClipboard

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

useClipboard

Demo

Hook that read and write to the user's clipboard.

Example

import React from 'react';
import { useClipboard } from 'react-essential-tools';

const Demo = () => {
  const [text, setText] = useState('');
  const { clipboardState, setClipboard, readClipboard } = useClipboard();

  return (
    <div>
      <input value={text} onChange={e => setText(e.target.value)} />

      <button onClick={() => setClipboard(text)}>copy</button>
      <button onClick={() => readClipboard()}>read</button>

      Clipboard value: {clipboardState}
    </div>
  )
}