How can I copy content
when it's clicked once? below is my code, but when I clicked and do ctrl + v, it's not been copied
class App extends Component {
state = {
value: "",
copied: false
};
render() {
return (
<div className="App">
<CopyToClipboard
text={this.state.value}
onCopy={text => this.setState({ copied: true, text })}
>
<span>content</span>
</CopyToClipboard>
{this.state.copied ? (
<span style={{ color: "red" }}>Copied.</span>
) : null}
</div>
);
}
}
You are not changing this.state.value
in your program. Try setting it in your code with which value you are trying to copy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.