Skip to content

Commit

Permalink
Fix warning regarding expo-random.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswilddev committed Mar 14, 2023
1 parent 00056c4 commit 536fe77
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 19 deletions.
8 changes: 8 additions & 0 deletions jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ jest.mock(`expo-image-picker`, () => {
};
});

jest.mock(`expo-crypto`, () => {
const uuid = jest.requireActual(`uuid`);

return {
randomUUID: () => uuid.v4(),
};
});

jest.mock(`expo-file-system`, () => {
const uuid = jest.requireActual(`uuid`);
const fs = jest.requireActual(`fs`);
Expand Down
75 changes: 65 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"react": "17.0.2",
"react-native": "0.66.4",
"react-test-renderer": "17.0.2",
"typescript": "4.5.5"
"typescript": "4.5.5",
"uuid": "^9.0.0"
},
"peerDependencies": {
"react": "*",
Expand All @@ -59,17 +60,16 @@
"events": "3.3.0",
"expo": "^48.0.0",
"expo-constants": "^14.2.1",
"expo-crypto": "^12.2.1",
"expo-file-system": "^15.2.2",
"expo-image-picker": "^14.1.1",
"expo-intent-launcher": "^10.5.2",
"expo-media-library": "^15.2.2",
"expo-permissions": "^14.1.1",
"expo-random": "^13.1.1",
"expo-secure-store": "^12.1.1",
"expo-standard-web-crypto": "^1.4.3",
"filter-validate-email": "1.1.3",
"react-native-gesture-handler": "^2.9.0",
"react-native-safe-area-context": "^4.5.0",
"uuid": "^8.3.2"
"react-native-safe-area-context": "^4.5.0"
}
}
6 changes: 3 additions & 3 deletions react-native/components/createStackRoutingComponent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all items in the stack are continuously rendered).
## Usage

```tsx
import * as uuid from "uuid";
import * as Crypto from "expo-crypto";
import React from "react";
import { Button, SafeAreaView, Text } from "react-native";
import {
Expand Down Expand Up @@ -237,10 +237,10 @@ export default () => {
<RoutingComponent
routeState={routeState}
pushA={() => {
setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeAKey`, parameters: null } ]);
setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeAKey`, parameters: null } ]);
}}
pushB={(value) => {
setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeBKey`, parameters: { value } } ]);
setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeBKey`, parameters: { value } } ]);
}}
pop={() => {
setRouteState(routeState.slice(0, routeState.length - 1));
Expand Down
4 changes: 2 additions & 2 deletions react-native/services/FileStore/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as uuid from "uuid";
import * as Crypto from "expo-crypto";
import * as FileSystem from "expo-file-system";
import type { FileStoreInterface } from "../../types/FileStoreInterface";

Expand Down Expand Up @@ -99,7 +99,7 @@ export class FileStore implements FileStoreInterface {
try {
this.operationsInProgress++;

const output = uuid.v4();
const output = Crypto.randomUUID();

await FileSystem.moveAsync({
from: fileUri,
Expand Down

0 comments on commit 536fe77

Please sign in to comment.