Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

hamsterbacke23/react-copy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplistic copy-to-clipboard component Build Status Dependencies

Works by selecting a string given as a prop and then copies it. Almost no dependencies.

Usage

npm install react-copy --save

or

yarn add react-copy
import Copy from 'react-copy';

...

<Copy textToBeCopied={this.state.text}>
    <button>
      Copy the text please please
    </button>
</Copy>

Properties

textToBeCopied

Type: PropTypes.string.isRequired

The text that should be copied on button click

children

Type: PropTypes.element.isRequired

Exactly one child is required as a click handler for copying, e.g. a button

onCopy

Type: PropTypes.func

A callback function called when copy function is called

style

Type: PropTypes.object

Optional style object

Example

For a real world use-case checkout a demo (https://github.com/hamsterbacke23/movierater)

Alternatives to this component

Also check out