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>
)
}
}
'프로그래밍(Programming) > 리액트 네이티브(React Native)' 카테고리의 다른 글
react-native(리액트 네이티브) API - Dimensions (0) | 2019.01.07 |
---|---|
react-native(리액트 네이티브) API - DatePickerAndroid (0) | 2019.01.07 |
react-native(리액트 네이티브) API - Border (0) | 2019.01.07 |
react-native(리액트 네이티브) API - AppState (0) | 2019.01.07 |
react-native(리액트 네이티브) API - Alert (0) | 2019.01.07 |