useCopyToClipboard
Copy text content to clipboard
The useCopyToClipboard
hook is helpful when you want to copy any text content to clipboard using the modern navigator.clipboard.writeText
method.
useCopyToClipboard
I love react!
Usage
Import the hook from @abhushanaj/react-hooks
and use in required component;
API Reference
Return Value
The hook returns a tuple with [copiedText, copyToClipboardFn]
signature.
Parameter | Type | Description | Default |
---|---|---|---|
copiedText | string|null | The last value copied text to clipboard. | null |
copyToClipboardFn | (textToCopy: string)=>void | Function to copy a value to clipboard. | N/A |