react-native - 在 expo 应用程序中使用库时 react-native-Uuid-generator 崩溃
问题描述
我想在使用 expo cli 构建的 ReactNative 应用程序中生成一个 uuid。当我从安装UUIDGenerator
时React-native-uuid-generator
,我得到undefined is not an object(evaluating ‘RNUUIDGenerator.getRandomUUID’..)
尝试了两个 diff 库,react-native-uuid
和React-native-uuid-generator
,同样的问题,认为它可能与 expo 不喜欢链接命令有关。
UUIDGenerator.getRandomUUID().then(uuid => console.log(uuid));
期望打印新的 uuid,实际上收到错误消息。
解决方案
react-native-uuid
与世博会合作。
npm install react-native-uuid --save
import uuid from 'react-native-uuid';
然后像
const uuid = uuid.v1();
推荐阅读
- linux - 带有来自变量的空格的 Docker args。使用方法>
- python-3.x - 在运行时创建嵌套字典
- azure - 如何使用 TestCafe 和 Yaml 在 Azure Build Pipeline 中将屏幕截图和视频保存为附件?
- python - 如何使用 Python Client for GKE 运行 GKE 作业?
- java - 在 Android Studio 中处理嵌套的触摸事件?
- javascript - 图像文件的数据正在从 ajax 发送到 php 脚本,但我不知道如何访问它
- google-ads-api - 如何获取与今年开始的广告系列相关的所有视频广告
- visual-studio-code - Makefile 或 task.json 用于编译 C++ 代码?
- excel - Excel-如何查找关键字的多个匹配项
- discord - Discord.py 机器人在使用特定命令后对用户的下一条消息做出反应