Code coverage report for src/CopyToClipboard.js

Statements: 100% (14 / 14)      Branches: 100% (6 / 6)      Functions: 100% (3 / 3)      Lines: 100% (6 / 6)      Ignored: 1 branch     

All files » src/ » CopyToClipboard.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29        6                 4 4 3           5              
import React from 'react';
import copy from 'copy-to-clipboard';
 
 
const CopyToClipboard = React.createClass({
  propTypes: {
    text: React.PropTypes.string.isRequired,
    children: React.PropTypes.node.isRequired,
    onCopy: React.PropTypes.func
  },
 
 
  onClick() {
    copy(this.props.text);
    if (this.props.onCopy) {
      this.props.onCopy(this.props.text);
    }
  },
 
 
  render() {
    return React.cloneElement(React.Children.only(this.props.children), {onClick: this.onClick});
  }
});
 
 
export default CopyToClipboard;