react-native(리액트 네이티브) API - Clipboard


const React = require('react')
const ReactNative = require('react-native')
const { Clipboard, View, Text } = ReactNative

export default class ClipboardExample extends React.Component {
state = {
content: 'Cotent will appear here',
}

_setClipboardContent = async () => {
Clipboard.setString('Hello World')
try {
const content = await Clipboard.getString()
this.setState({content})
} catch (e) {
this.setState({ content: e.message })
}
}

render() {
return(
<View>
<Text onPress={this._setClipboardContent} style={{color: 'blue'}}>
Tap to put "Hello World" in the clipboard
</Text>
<Text sytle={{color: 'red', marginTop: 20}}>
{this.state.content}
</Text>
</View>
)
}
}


+ Recent posts