clipboard wrapper component for react
yarn add react # requirement
yarn add clipboard # requirement
yarn add @axetroy/react-clipboard
import { Component } from "react";
import ReactClipboard from "@axetroy/react-clipboard";
class App extends Component {
render() {
return (
<div>
<ReactClipboard
value={"you will copy me!"}
onSuccess={() => {
console.log("copy success");
}}
onError={() => {
console.error("copy error");
}}
>
<input type="button" value="Click me & copy that." />
</ReactClipboard>
</div>
);
}
}
-
value: string
any string you want to copy
-
onSuccess: function
success callback
-
onError: function
error callback
git clone https://github.com/axetroy/react-clipboard.git
yarn
yarn start
The MIT License