react-clipboard2

1.0.4 • Public • Published

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

Package Sidebar

Install

npm i react-clipboard2

Weekly Downloads

0

Version

1.0.4

License

ISC

Last publish

Collaborators

  • maat