An open API service indexing awesome lists of open source software.

https://github.com/animify/usecopy

📋 A React hook to copy dynamic textual data.
https://github.com/animify/usecopy

clipboard copy hooks react reacthooks

Last synced: 7 months ago
JSON representation

📋 A React hook to copy dynamic textual data.

Awesome Lists containing this project

README

          

# useCopy 📋

A React Hook that provides an easy interface to copy textual data.

```js
import React from 'react';
import useCopy from 'use-copy';

function Count() {
const [copied, copy, setCopied] = useCopy("Text to copy");

const copyText = () => {
copy();

setTimeout(() => {
setCopied(false);
}, 3000);
};

return (


{ copied ? "Copied to clipboard" : Copy text }

);
}
```

[Full example on Code Sandbox](https://codesandbox.io/s/101qo4m9n3)

## Install

```bash
# Yarn
yarn add use-copy

# NPM
npm install use-copy
```

## Features

- Feather light
- Pass dynamic text
- Easy interface
- Full Typescript support
- Uses the battle-tested [copy-to-clipboard](https://github.com/sudodoki/copy-to-clipboard)

## Prerequisites

⚠️ React hooks require `react` at version 16.7.0-alpha.0 or higher.

## Issues & suggestions

If you find any runtime issues or have any suggestions on how to improve the package please do open an [issue](https://github.com/animify/useCopy/issues)!

## License

[MIT License](LICENSE)