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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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 react-copy-text
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>
)
<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.
Feel free to dive in! Open an issue or submit PRs.
MIT © Alan Shaw
A (?°?°???TABLEFLIP side project.