- Let's start off by creating a ClipboardText component that both uses a Text component to display text and provides the ability to copy its contents to the clipboard via long press. Let's create a component folder in the root of the project, and a ClipboardText.js file inside of it. We'll start by importing dependencies, as follows:
import React, { Component } from 'react';import { StyleSheet, Text, View, Clipboard, TextInput} from 'react-native';import Button from 'react-native-button';
- Next we'll define the App class and the initial state. We will use the clipboardContent property on state for storing text being pasted from the clipboard into the UI, as follows:
export default class App extends Component { state = {