1.3.0 • Published 5 years ago

react-carabiner v1.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

react-carabiner 🧗‍

npm npm bundle size npm GitHub GitHub

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>
  );
}