From ed35d3e8df711987611fb13e2d34e3aeef436e20 Mon Sep 17 00:00:00 2001 From: mrevanzak Date: Sun, 26 Nov 2023 15:12:51 +0700 Subject: [PATCH] fix(expo): use expo-crypto to generate UUID --- apps/expo/package.json | 1 - apps/expo/src/components/ProductForm.tsx | 4 ++-- pnpm-lock.yaml | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/expo/package.json b/apps/expo/package.json index 5f9ddae..dbdde35 100644 --- a/apps/expo/package.json +++ b/apps/expo/package.json @@ -51,7 +51,6 @@ "superjson": "1.13.1", "tus-js-client": "^3.1.1", "use-tus": "^0.7.3", - "uuid": "^9.0.1", "zod": "^3.21.4", "zustand": "^4.4.6" }, diff --git a/apps/expo/src/components/ProductForm.tsx b/apps/expo/src/components/ProductForm.tsx index d60d0b4..d5dfa64 100644 --- a/apps/expo/src/components/ProductForm.tsx +++ b/apps/expo/src/components/ProductForm.tsx @@ -8,6 +8,7 @@ import { Text, View, } from "react-native-ui-lib"; +import { randomUUID } from "expo-crypto"; import { useLocalSearchParams, useRouter } from "expo-router"; import Input from "@/components/forms/Input"; import Picker from "@/components/forms/Picker"; @@ -19,7 +20,6 @@ import { useUser } from "@clerk/clerk-expo"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import { zodResolver } from "@hookform/resolvers/zod"; import { FormProvider, useForm } from "react-hook-form"; -import { v4 } from "uuid"; import { z } from "zod"; const schema = z.object({ @@ -64,7 +64,7 @@ export default function ProductForm({ edit }: ProductFormProps) { }); const { handleSubmit, reset } = methods; const onSubmit = handleSubmit(async (data) => { - const productId = edit ? productDetail?.id : v4(); + const productId = edit ? productDetail?.id : randomUUID(); const filePath = `${user?.id}/${productId}.png`; const { error } = await onUpload("products", filePath); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fdd7de8..fd6278c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -137,9 +137,6 @@ importers: use-tus: specifier: ^0.7.3 version: 0.7.3(react@18.2.0)(tus-js-client@3.1.1) - uuid: - specifier: ^9.0.1 - version: 9.0.1 zod: specifier: ^3.21.4 version: 3.22.4