Skip to content

fix: Add polyfill for crypto.getRandomValues in React Native#952

Open
Arshiash80 wants to merge 1 commit intoFaridSafi:masterfrom
Arshiash80:fix/polyfill-for-crypto-get-random-values
Open

fix: Add polyfill for crypto.getRandomValues in React Native#952
Arshiash80 wants to merge 1 commit intoFaridSafi:masterfrom
Arshiash80:fix/polyfill-for-crypto-get-random-values

Conversation

@Arshiash80
Copy link

This PR adds a polyfill for the global crypto.getRandomValues method in React Native by installing react-native-get-random-values. This polyfill is required because React Native does not natively support crypto.getRandomValues, which is used by uuid and other libraries that rely on it for random ID generation.

The polyfill ensures that these libraries can function correctly in a React Native environment without causing the "Error: crypto.getRandomValues() not supported" issue.

Fixes #950.

Copy link

@josedelapazjr josedelapazjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM! But not sure how to test it and I need this fix asap, please. 🙏

@Arshiash80
Copy link
Author

Code LGTM! But not sure how to test it and I need this fix asap, please. 🙏

Thanks for the review.

Since this change is just importing the react-native-get-random-values polyfill, you can test it by running the app on a React Native platform (iOS or Android) and verifying that UUID generation works without errors.

For example, you can check any feature that uses uuid to ensure it doesn't throw a "crypto.getRandomValues() not supported" error anymore.

@govi218
Copy link

govi218 commented Oct 24, 2024

Should fix #953 as well

@scansio
Copy link

scansio commented Dec 1, 2024

This PR should be merged asap because I had the same issue ...

@dpakakpo4
Copy link

Hi why can't you use react-native-uuid or is it not adapted.

@Umair-max
Copy link

same issue here

@dpakakpo4
Copy link

same issue here

https://www.npmjs.com/package/rn-use-google-places-autocomplete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uuid library doesn't work well with expo

6 participants