react-native/RNTester/js/ClipboardExample.js
Ignacio Olaciregui 7b3c91ef16 Fix inline styles eslint warnings for examples (#22123)
Summary:
Fixes `react-native/no-inline-styles` warning for several examples. I'm limiting the size of this PR to make it simpler to review.
Pull Request resolved: https://github.com/facebook/react-native/pull/22123

Reviewed By: RSNara

Differential Revision: D12929701

Pulled By: TheSavior

fbshipit-source-id: 7a976f2208b557fcfda46d5b586b30652c550eb2
2018-11-08 17:20:33 -08:00

64 lines
1.3 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const {Clipboard, View, Text, StyleSheet} = ReactNative;
class ClipboardExample extends React.Component<{}, $FlowFixMeState> {
state = {
content: 'Content 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={styles.label}>
Tap to put "Hello World" in the clipboard
</Text>
<Text style={styles.content}>{this.state.content}</Text>
</View>
);
}
}
exports.title = 'Clipboard';
exports.description = 'Show Clipboard contents.';
exports.examples = [
{
title: 'Clipboard.setString() and getString()',
render() {
return <ClipboardExample />;
},
},
];
const styles = StyleSheet.create({
label: {
color: 'blue',
},
content: {
color: 'red',
marginTop: 20,
},
});