# react-copy-to-clipboard
react 复制粘贴
```
npm install --save react react-copy-to-clipboard
import React from'react';
import ReactDOM from'react-dom';
import {CopyToClipboard} from'react-copy-to-clipboard';
class App extends React.Component {
state = {
value: '',
copied: false,
};
render() {
return (
<input value\={this.state.value}
onChange\={({target: {value}}) => this.setState({value, copied: false})} />
<CopyToClipboard text\={this.state.value}
onCopy\={() => this.setState({copied: true})}>
Copy to clipboard with span
<CopyToClipboard text\={this.state.value}
onCopy\={() => this.setState({copied: true})}>
Copy to clipboard with button
{this.state.copied ? Copied. : null}
);
}
}
const appRoot = document.createElement('div');
document.body.appendChild(appRoot);
ReactDOM.render(, appRoot);
```