DefinitelyTyped/types/react-native-share-extension/react-native-share-extension-tests.tsx
Haseeb Majid 5eeffbdb87 Added react-native-share-extension (#41306)
* Added React Native Share Extension

* Fixed Linting Issues

Fixed linting issues, added tests.

* Fixed other linting issues

Data returns a promise.

* Removed Public from state

Removed public from state.
2020-01-02 15:56:33 -08:00

40 lines
1.1 KiB
TypeScript

import * as React from 'react';
import ShareExtension from 'react-native-share-extension';
import { Text, View } from 'react-native';
export default class Share extends React.Component {
state = {
type: '',
value: '',
};
async componentDidMount() {
try {
const { type, value } = await ShareExtension.data();
await ShareExtension.data();
ShareExtension.openURL('sample://example/url');
ShareExtension.close();
this.setState({
type,
value,
});
} catch (e) {
console.log('errrr', e);
}
}
render() {
return (
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}>
<View
style={{ borderColor: 'green', borderWidth: 1, backgroundColor: 'white', height: 200, width: 300 }}
>
<Text>type: {this.state.type}</Text>
<Text>value: {this.state.value}</Text>
</View>
</View>
);
}
}