From 13e0acd27da6916613d1a8c97e665fef68c69d7d Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Wed, 18 Mar 2026 10:25:58 +0000 Subject: [PATCH] refactor: replace `nanoid` with `Math.random()` for ID generation and remove the `react-native-get-random-values` dependency. --- index.ts | 1 - package-lock.json | 19 ------------------- package.json | 1 - src/context/AppContext.tsx | 5 ++--- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/index.ts b/index.ts index 2dab631..5fd059f 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,3 @@ -import 'react-native-get-random-values'; import { registerRootComponent } from 'expo'; import App from './App'; diff --git a/package-lock.json b/package-lock.json index eec3255..828954d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,6 @@ "react": "19.1.0", "react-dom": "19.1.0", "react-native": "0.81.5", - "react-native-get-random-values": "^2.0.0", "react-native-safe-area-context": "4.10.1", "react-native-screens": "~3.31.1", "react-native-web": "^0.21.0" @@ -5280,12 +5279,6 @@ "integrity": "sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==", "license": "Apache-2.0" }, - "node_modules/fast-base64-decode": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz", - "integrity": "sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q==", - "license": "MIT" - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -8128,18 +8121,6 @@ } } }, - "node_modules/react-native-get-random-values": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/react-native-get-random-values/-/react-native-get-random-values-2.0.0.tgz", - "integrity": "sha512-wx7/aPqsUIiWsG35D+MsUJd8ij96e3JKddklSdrdZUrheTx89gPtz3Q2yl9knBArj5u26Cl23T88ai+Q0vypdQ==", - "license": "MIT", - "dependencies": { - "fast-base64-decode": "^1.0.0" - }, - "peerDependencies": { - "react-native": ">=0.81" - } - }, "node_modules/react-native-is-edge-to-edge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/react-native-is-edge-to-edge/-/react-native-is-edge-to-edge-1.3.1.tgz", diff --git a/package.json b/package.json index 2e83b84..32911de 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "react": "19.1.0", "react-dom": "19.1.0", "react-native": "0.81.5", - "react-native-get-random-values": "^2.0.0", "react-native-safe-area-context": "4.10.1", "react-native-screens": "~3.31.1", "react-native-web": "^0.21.0" diff --git a/src/context/AppContext.tsx b/src/context/AppContext.tsx index e68de58..43f777a 100644 --- a/src/context/AppContext.tsx +++ b/src/context/AppContext.tsx @@ -7,7 +7,6 @@ import React, { createContext, useContext, useEffect, useMemo, useState } from 'react'; import { Appointment, Barber, BarberShop, CartItem, Order, Product, Service, User, WaitlistEntry, AppNotification } from '../types'; import { supabase } from '../lib/supabase'; -import { nanoid } from 'nanoid'; import * as Notifications from 'expo-notifications'; import * as Device from 'expo-device'; import { Platform } from 'react-native'; @@ -218,7 +217,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { }; const register = (payload: any) => { - const id = nanoid(); + const id = Math.random().toString(36).substring(2, 15); const newUser: User = { ...payload, id }; setUser(newUser); return newUser; @@ -242,7 +241,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { }, 0); const newOrder: Order = { - id: nanoid(), + id: Math.random().toString(36).substring(2, 15), shopId, customerId, items: shopItems,