Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-clipboard2

maat3ISC1.0.4

Component to allow the user to easily copy text.

component, react-component, react, copy to clipboard, clipboard

readme

react-clipboard2

Component to allow the user to easily copy text.

Install

npm install react-clipboard2 --save

Usage

var React = require("react");
var ReactDOM = require("react-dom");
var Clipboard = require("react-clipboard2");

var App = React.createClass({

  render: function() {
    return (
      <div>
        <Clipboard  onFail={handleFail.bind(this)}  onCopy={handleCopy.bind(this)} text="this text will be copyed">
            <button>Click here to copy</button>
        </Clipboard>
      </div>
    );
  },

  handleCopy : function(text) {
    alert("copied: " + text);
  }

  handleFail: function () {
    alert('failed');
  }

});

ReactDOM.render(
  <App />,
  document.querySelector("#app")
);