Socket
Socket
Sign inDemoInstall

react-x-clipboard

Package Overview
Dependencies
2
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-x-clipboard

Cross-platform clipboard for ReactDOM and React Native apps.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
94.5 kB
Created
Weekly downloads
 

Readme

Source

react-x-clipboard

npm npm npm

Cross-platform clipboard for ReactDOM and React Native apps.

Getting Started

Install react-x-clipboard using yarn:

yarn add react-x-clipboard

Usage

import React from 'react';
import PropTypes from 'prop-types';
import {Text, Touchable, View} from 'react-native';
import Clipboard from 'react-x-clipboard';


class App extends React.Component {

  // --------------------------------------------------
  // Props
  // --------------------------------------------------
  static propTypes = {
    user: PropTypes.object.isRequired,
  };

  static defaultProps = {
  };

  // --------------------------------------------------
  // Event Handlers
  // --------------------------------------------------

  @bind
  handlePress() {
    Clipboard.setString(this.props.user.name);
  }

  // --------------------------------------------------
  // Render
  // --------------------------------------------------
  render() {
    return (
      <View>
        ...
        <Touchable
          onPress={this.handlePress}>
          <Text>
            {'Copy Name'}
          </Text>
        </Touchable>
      </View>
    );
  }

}

API

async getString

Returns a promise that resolves to the string currently copied to the clipboard. This currently is not supported on the DOM version. Please submit a PR with this functionality!

async setString(string)

Copies the string to the clipboard.

Contributing

If you have any ideas on how this module could be better, create an Issue or submit a PR.

Keywords

FAQs

Last updated on 30 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc