はじめに
web環境のUUIDと同じ以下の生成方法を試したところ
import { v4 as uuidv4 } from "uuid";
const id = uuidv4();
こんなエラーが出ました。
Possible unhandles promise rejection (id: 0):
Error: crypto.getRandomValues() not supported.
解決できたので共有します。
方法
こちらの公式が参考になります。
具体的にはインポートするときに、以下の文章を追加するだけでした。
// これを追加する
import "react-native-get-random-values";
import { v4 as uuidv4 } from "uuid";
終わりに
さっくりと解決しましたが、参考になるかもしれないので、共有しておきます。