Skip to content

Commit 536fe77

Browse files
committed
Fix warning regarding expo-random.
1 parent 00056c4 commit 536fe77

File tree

5 files changed

+82
-19
lines changed

5 files changed

+82
-19
lines changed

jest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ jest.mock(`expo-image-picker`, () => {
108108
};
109109
});
110110

111+
jest.mock(`expo-crypto`, () => {
112+
const uuid = jest.requireActual(`uuid`);
113+
114+
return {
115+
randomUUID: () => uuid.v4(),
116+
};
117+
});
118+
111119
jest.mock(`expo-file-system`, () => {
112120
const uuid = jest.requireActual(`uuid`);
113121
const fs = jest.requireActual(`fs`);

package-lock.json

Lines changed: 65 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"react": "17.0.2",
3636
"react-native": "0.66.4",
3737
"react-test-renderer": "17.0.2",
38-
"typescript": "4.5.5"
38+
"typescript": "4.5.5",
39+
"uuid": "^9.0.0"
3940
},
4041
"peerDependencies": {
4142
"react": "*",
@@ -59,17 +60,16 @@
5960
"events": "3.3.0",
6061
"expo": "^48.0.0",
6162
"expo-constants": "^14.2.1",
63+
"expo-crypto": "^12.2.1",
6264
"expo-file-system": "^15.2.2",
6365
"expo-image-picker": "^14.1.1",
6466
"expo-intent-launcher": "^10.5.2",
6567
"expo-media-library": "^15.2.2",
6668
"expo-permissions": "^14.1.1",
67-
"expo-random": "^13.1.1",
6869
"expo-secure-store": "^12.1.1",
6970
"expo-standard-web-crypto": "^1.4.3",
7071
"filter-validate-email": "1.1.3",
7172
"react-native-gesture-handler": "^2.9.0",
72-
"react-native-safe-area-context": "^4.5.0",
73-
"uuid": "^8.3.2"
73+
"react-native-safe-area-context": "^4.5.0"
7474
}
7575
}

react-native/components/createStackRoutingComponent/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ all items in the stack are continuously rendered).
66
## Usage
77

88
```tsx
9-
import * as uuid from "uuid";
9+
import * as Crypto from "expo-crypto";
1010
import React from "react";
1111
import { Button, SafeAreaView, Text } from "react-native";
1212
import {
@@ -237,10 +237,10 @@ export default () => {
237237
<RoutingComponent
238238
routeState={routeState}
239239
pushA={() => {
240-
setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeAKey`, parameters: null } ]);
240+
setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeAKey`, parameters: null } ]);
241241
}}
242242
pushB={(value) => {
243-
setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeBKey`, parameters: { value } } ]);
243+
setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeBKey`, parameters: { value } } ]);
244244
}}
245245
pop={() => {
246246
setRouteState(routeState.slice(0, routeState.length - 1));

react-native/services/FileStore/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as uuid from "uuid";
1+
import * as Crypto from "expo-crypto";
22
import * as FileSystem from "expo-file-system";
33
import type { FileStoreInterface } from "../../types/FileStoreInterface";
44

@@ -99,7 +99,7 @@ export class FileStore implements FileStoreInterface {
9999
try {
100100
this.operationsInProgress++;
101101

102-
const output = uuid.v4();
102+
const output = Crypto.randomUUID();
103103

104104
await FileSystem.moveAsync({
105105
from: fileUri,

0 commit comments

Comments
 (0)