Skip to content

axetroy/react-clipboard

Repository files navigation

react-clipboard

clipboard wrapper component for react

Online demo

Install

yarn add react          # requirement
yarn add clipboard      # requirement
yarn add @axetroy/react-clipboard

Usage

import { Component } from "react";
import ReactClipboard from "@axetroy/react-clipboard";

class App extends Component {
  render() {
    return (
      <div>
        <ReactClipboard
          value={"you will copy me!"}
          onSuccess={() => {
            console.log("copy success");
          }}
          onError={() => {
            console.error("copy error");
          }}
        >
          <input type="button" value="Click me & copy that." />
        </ReactClipboard>
      </div>
    );
  }
}

Props

  • value: string

    any string you want to copy

  • onSuccess: function

    success callback

  • onError: function

    error callback

Run the Demo

git clone https://github.com/axetroy/react-clipboard.git
yarn
yarn start

License

The MIT License