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

https://github.com/tableflip/react-copy-text

Copy text to the clipboard like it's 1999
https://github.com/tableflip/react-copy-text

Last synced: about 1 year ago
JSON representation

Copy text to the clipboard like it's 1999

Awesome Lists containing this project

README

          

# react-copy-text

[![Build Status](https://travis-ci.org/tableflip/react-copy-text.svg?branch=master)](https://travis-ci.org/tableflip/react-copy-text) [![dependencies Status](https://david-dm.org/tableflip/react-copy-text/status.svg)](https://david-dm.org/tableflip/react-copy-text) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

> Copy text to the clipboard like it's 1999

Beautifully simples React component to copy the `text` you give to it, with optional `onCopied` callback so you know when it's done.

## Install

```sh
npm install react-copy-text
```

## Usage

```js
import React, { Component } from 'react'
import CopyText from 'react-copy-text'

export default class App extends Component {
state = {textToCopy: ''}

onButtonClick = () => this.setState({ textToCopy: 'NOW: ' + Date.now() })
onCopied = (text) => console.log(`${text} was copied to the clipboard`)

render () {
return (


Copy some text


)
}
}
```

## API

### ``

#### `text`

Type: `PropTypes.string`

The text to copy to the clipboard.

#### `onCopied`

Type: `PropTypes.func`

Callback function called after the text has been copied to the clipboard. Passed the text that was copied.

## Contribute

Feel free to dive in! [Open an issue](https://github.com/tableflip/react-copy-text/issues/new) or submit PRs.

## License

[MIT](LICENSE) © Alan Shaw

---

A [(╯°□°)╯︵TABLEFLIP](https://tableflip.io) side project.