mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
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.
This commit is contained in:
committed by
Ryan Cavanaugh
parent
bf8cc8a772
commit
5eeffbdb87
18
types/react-native-share-extension/index.d.ts
vendored
Normal file
18
types/react-native-share-extension/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for react-native-share-extension 2.0
|
||||
// Project: https://github.com/alinz/react-native-share-extension
|
||||
// Definitions by: Haseeb Majid <https://github.com/hmajid230>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface ShareData {
|
||||
value: string;
|
||||
type: 'text/plain' | 'images/*';
|
||||
}
|
||||
|
||||
interface ShareExtension {
|
||||
close(): void;
|
||||
data(): Promise<ShareData>;
|
||||
openURL(uri: string): void;
|
||||
}
|
||||
|
||||
declare const RNShareExtension: ShareExtension;
|
||||
export default RNShareExtension;
|
||||
@@ -0,0 +1,39 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-native-share-extension/tsconfig.json
Normal file
24
types/react-native-share-extension/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react-native"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-share-extension-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-native-share-extension/tslint.json
Normal file
1
types/react-native-share-extension/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user