blob: 0defba5308907d7f83f0427b79d23d678c3983ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import React, { Component } from 'react'
import { writeToClipboard } from 'app/utils'
export default class CopyToClipboardButton extends Component {
state = {
copied: false,
}
handleClick() {
writeToClipboard(this.props.data)
this.setState({ copied: true })
}
render() {
return (
<button
className={this.state.copied ? 'copyButton copied' : 'copyButton'}
onClick={this.handleClick.bind(this)}
>
{this.state.copied ? 'Copied!' : 'Copy'}
</button>
)
}
}
|