react-carabiner
v1.3.0
Published
A React Hook to copy to the clipboard
Downloads
6
Maintainers
Readme
react-carabiner 🧗
A React Hook to copy to the clipboard.
Install
$ npm i react-carabiner
Usage
The useCarabiner
hook returns a tuple with two values:
- The state variable
- A function to update the state value
import React from 'react';
import useCarabiner from 'react-carabiner';
function Example() {
const [clipboard, updateClipboard] = useCarabiner();
const sampleText = 'Click to copy my text!';
return (
<div>
<p>Current clipboard content: {clipboard}</p>
<button onClick={() => updateClipboard(sampleText)}>
{sampleText}
</button>
</div>
);
}