deepanshu katyal
deepanshu katyal

Reputation: 671

React native uuid [Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported]

In React native project uuid library giving runtime error

Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported

Upvotes: 1

Views: 3592

Answers (1)

deepanshu katyal
deepanshu katyal

Reputation: 671

"getRandomValues() not supported"

This error occurs in environments where the standard crypto.getRandomValues() API is not supported. This issue can be resolved by adding an appropriate polyfill:

React Native

Install react-native-get-random-values
Import it before uuid:
import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';

Upvotes: 7

Related Questions