Closed Coder8221 closed 3 months ago
For anyone experiencing this issue, the "easy" way to resolve this is by using react-native-get-random-values@1.8.0 - ref
other useful threads about it: https://github.com/expo/expo/issues/17270 https://github.com/expo/expo/issues/20906
Team is working on an option to roll your own crypto package as well as some other providers.
This will enable to use our recommended package (react-native-get-random-values
) or expo-crypto if targeting Expo. Similar to how we let you use the default async-storage or roll your own.
Closing this for now, will have some news in the future.
Description In setup of Segment in an expo managed project with typescript, after installing the required packages using this command:
npm install --save @segment/analytics-react-native @segment/sovran-react-native react-native-get-random-values
in App.tsx, adding in createClient() to initialise Segment, it causes the already included Crypto.getRandomValues() from expo-crypto method to break saying TypeError: undefined is not a function.This only occurs in android and not ios.
Related packages and versions: "react-native": "0.71.7", "expo-crypto": "~12.2.1", "@segment/analytics-react-native": "^2.17.0", "@segment/sovran-react-native": "^1.0.4", "react-native-get-random-values": "^1.10.0",
Steps to reproduce Add createClient method with writeKey from segment and in the code include the following from package expo-crypto (import * as Crypto from 'expo-crypto';):
Run this on android simulator or on physical device and it will throw an error TypeError: undefined is not a function
Expected behavior createClient for segment and Crypto.getRandomValues from expo-crypto will work without breaking.
Actual behavior throws an error TypeError: undefined is not a function on Crypto.getRandomValues()