0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Expo + React NativeでUUIDを生成する方法

Posted at

はじめに

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";

終わりに

さっくりと解決しましたが、参考になるかもしれないので、共有しておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?