reaccionar copia al portapapeles
onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}
Disgusted Dugong
onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}
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>
<buttononClick={() => navigator.clipboard.writeText("Copy this text to clipboard")}>
Copy
</button>
import Clipboard from '@react-native-clipboard/clipboard';
Clipboard.setString('Lorem Ipsum');
<button
onClick={() => navigator.clipboard.writeText('Copy this text to clipboard')}
>
Copy
</button>
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