react-clipboard-function-component
v1.0.1
Published
![img](https://img.shields.io/github/license/icepy/react-clipboard-function-component.svg) ![img](https://img.shields.io/github/package-json/v/icepy/react-clipboard-function-component.svg)
Downloads
14
Readme
ReactClipboardFunctionComponent
react clipboard function component
Install
$ yarn add react-clipboard-function-component --save
Used
import React from "react";
import * as ReactDOM from "react-dom";
import ReactClipboardFunctionComponent from "../lib";
class Home extends React.Component {
constructor(props){
super(props);
this.state = {
username: ""
}
}
render(){
const { username } = this.state;
return (
<div>
<button onClick={
() => {
this.setState({
username: "icepy"
})
}
}>
<ReactClipboardFunctionComponent
text={username}
onCopy={() => {
// 复制成功
}}
>
copy
</ReactClipboardFunctionComponent>
</button>
</div>
)
}
}
ReactDOM.render(
<Home />,
document.getElementById("app"),
);