Skip to content

Commit c0f6cb8

Browse files
authored
Added typescript definition and fixed the exports #3
2 parents 6c23d2a + b5a6909 commit c0f6cb8

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ Since native platforms already have ways to create GUIDs that are useful, creati
5353
Check the example under `example` folder for it's usage.
5454

5555
```javascript
56-
import { createGuid } from "react-native-create-guid";
56+
import createGuid from "react-native-create-guid";
5757

5858
// in an async function;
5959
const guid = await createGuid();
6060

6161
// using promises
62-
createGuid().then(guid => console.log(guid));
62+
createGuid().then((guid) => console.log(guid));
6363
```

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "react-native-create-guid" {
2+
declare function createGuid(): Promise<string>;
3+
4+
export default createGuid;
5+
}

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { NativeModules } from 'react-native';
1+
import { NativeModules } from "react-native";
22

3-
const { CreateGuid } = NativeModules;
3+
const {
4+
CreateGuid: { createGuid },
5+
} = NativeModules;
46

5-
export default CreateGuid;
7+
export default createGuid;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "react-native-create-guid",
33
"title": "React Native Create Guid",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"description": "TODO",
66
"main": "index.js",
7+
"types": "index.d.ts",
78
"scripts": {
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},

0 commit comments

Comments
 (0)