在 expo 应用程序中使用库时 react-native-Uuid-generator 崩溃

Crash in react-native-Uuid-generator when using library in expo app

我想在使用 expo cli 构建的 ReactNative 应用程序中生成一个 uuid。当我从 React-native-uuid-generator 安装 UUIDGenerator 时,我得到 undefined is not an object(evaluating ‘RNUUIDGenerator.getRandomUUID’..)

尝试了两个 dif 库,react-native-uuidReact-native-uuid-generator,同样的问题,认为这可能与 expo 不喜欢 link 命令有关。

UUIDGenerator.getRandomUUID().then(uuid => console.log(uuid));

期待打印新的 uuid,实际上收到错误消息。

react-native-uuid 与世博会合作。

npm install react-native-uuid --save

import uuid from 'react-native-uuid';

然后生成类似

的uuid
const uuid = uuid.v1();