tableflip/react-copy-text

Name: react-copy-text

Owner: TABLEFLIP

Description: Copy text to the clipboard like it's 1999

Created: 2017-12-01 11:41:41.0

Updated: 2017-12-14 20:53:37.0

Pushed: 2018-01-23 08:48:15.0

Homepage: https://www.npmjs.com/package/react-copy-text

Size: 75

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

react-copy-text

Build Status dependencies Status JavaScript Style Guide

Copy text to the clipboard like it's 1999

Beautifully simples React component to copy the text you give to it, with optional onCopied callback so you know when it's done.

Install
install react-copy-text
Usage
rt React, { Component } from 'react'
rt CopyText from 'react-copy-text'

rt default class App extends Component {
ate = {textToCopy: ''}

ButtonClick = () => this.setState({ textToCopy: 'NOW: ' + Date.now() })
Copied = (text) => console.log(`${text} was copied to the clipboard`)

nder () {
return (
  <div>
    <button onClick={this.onButtonClick}>Copy some text</button>
    <CopyText text={this.state.textToCopy} onCopied={this.onCopied} />
  </div>
)


API
<CopyText />
text

Type: PropTypes.string

The text to copy to the clipboard.

onCopied

Type: PropTypes.func

Callback function called after the text has been copied to the clipboard. Passed the text that was copied.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw


A (?°?°???TABLEFLIP side project.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.