Unleash / unleash-proxy-client-js

A browser client that can be used together with the unleash-proxy.
Apache License 2.0
45 stars 46 forks source link

error "crypto.getRandomValues) not supported" in react-native application when using useVariant() in iOS simulator #223

Closed Erwan-DATIN closed 3 weeks ago

Erwan-DATIN commented 1 month ago

error "crypto.getRandomValues) not supported" in react-native application (0.71) in iOS simulator

Currently testing unleash and more precisely variants I encounter an error (does not occur in my testing web application):

crypto.getRandomValues) not supported

Steps to reproduce the bug

In a react-native application (my rn version is currently v0.71.x) useVariant()

import { useVariant } from '@unleash/proxy-client-react';
///....
const myVariant = useVariant('myVariant'); // will lead to this error in iOS simulator

Expected behavior

Should not throw this error

Logs, error output, etc.

See screenshot below.

Screenshots

image

Additional context

react-native 0.71+

Unleash version

@unleash/proxy-client-react@4.3.0

Subscription type

None

Hosting type

Hosted by Unleash

SDK information (language and version)

No response

ivarconr commented 1 month ago

Easiest way to fix this for end-users would be to install and add import 'react-native-get-random-values' at the top of their React Native / Expo app, like mentioned here: https://www.npmjs.com/package/uuid#react-native--expo

(already discussed in https://github.com/Unleash/unleash-proxy-client-js/issues/87)