“Salin ke Clipboard React Native” Kode Jawaban

bereaksi salinan ke clipboard

onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}
Disgusted Dugong

Buat tombol salin bereaksi asli

import Clipboard from '@react-native-community/clipboard';

<TouchableOpacity onPress={() => Clipboard.setString('[email protected]')}>
  <View>
    <Text style={{color: 'red', fontSize: 14 , fontFamily:'Arial', fontStyle: 'bold', textAlign: 'center', marginTop: 3, marginLeft: 25, marginBottom: 17}}> 
                [email protected]
    </Text>
  </View>
</TouchableOpacity>
Weary Wren

Bereaksi Salin ke Tombol Clipboard

 <buttononClick={() => navigator.clipboard.writeText("Copy this text to clipboard")}>
  Copy
</button>
Dayanaohhnana

Salin ke Clipboard React Native

import Clipboard from '@react-native-clipboard/clipboard';

Clipboard.setString('Lorem Ipsum');
christophe kwizera

bereaksi salinan ke clipboard

<button 
  onClick={() =>  navigator.clipboard.writeText('Copy this text to clipboard')}
>
  Copy
</button>
Funny Flatworm

bereaksi salinan asli ke clipboard

import React, { useState } from 'react'
import { SafeAreaView, View, Text, TouchableOpacity, Clipboard, StyleSheet } from 'react-native'

const App = () => {
  const [copiedText, setCopiedText] = useState('')

  const copyToClipboard = () => {
    Clipboard.setString('hello world')
  }

  const fetchCopiedText = async () => {
    const text = await Clipboard.getString()
    setCopiedText(text)
  }

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <View style={styles.container}>
        <TouchableOpacity onPress={() => copyToClipboard()}>
          <Text>Click here to copy to Clipboard</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => fetchCopiedText()}>
          <Text>View copied text</Text>
        </TouchableOpacity>

        <Text style={styles.copiedText}>{copiedText}</Text>
      </View>

    </SafeAreaView>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  copiedText: {
    marginTop: 10,
    color: 'red'
  }
})

export default App
Abdullah Al Muzaki

Jawaban yang mirip dengan “Salin ke Clipboard React Native”

Pertanyaan yang mirip dengan “Salin ke Clipboard React Native”

Lebih banyak jawaban terkait untuk “Salin ke Clipboard React Native” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya