react-recipes
Version:
A React Hooks utility library containing popular customized hooks
32 lines (22 loc) • 643 B
Markdown
string to the clipboard
- `duration?: Number`: Duration of "on/success" state, default is `2000`.
- `isCopied: Bool`: true when string was copied for the length of the duration.
- `setIsCopied: Function(string)`: Copies the string to the clipboard
```js
import { useCopyClipboard } from "react-recipes";
const App = () => {
const [isCopied, setIsCopied] = useCopyClipboard();
const copy = () => {
setIsCopied("This string is copied");
};
return (
<button onClick={copy} type="button">
{isCopied ? "Copied" : "Copy"}
</button>
);
};
```
Copies any