reactjs - 如何修复设备: (3:2294) null is not an object (evaluating 'f.getRandomBase64' ) uuid react-native

标签 reactjs react-native expo uuid

我正在使用零食博览会学习react-native,并尝试为我的组件生成随机的唯一编号,但当我在 Android 和 iOS 上测试我的应用程序时出现错误,但它在网络上运行良好:

Device: (3:2294) null is not an object (evaluating 'f.getRandomBase64')

这是我的代码

import * as React from 'react';
import { View } from 'react-native';

import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';

export default function App() {
  return (
    <View>
     {uuidv4()}
    </View>
  );
}

这是我的 snack link

最佳答案

安装react-native-get-random-values后重建应用程序为我解决了这个问题。

安装react-native-get-random-values后:

  1. cd ios && pod install && cd ..
  2. 从模拟器/设备中删除了该应用并重新安装。
PS。调试器工作时并未出现此问题。

关于reactjs - 如何修复设备: (3:2294) null is not an object (evaluating 'f.getRandomBase64' ) uuid react-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61497199/

相关文章:

reactjs - 我可以从 React 项目创建 Windows exe 吗

sorting - Realm React native 排序顺序

javascript - 错误!错误 : EPERM: operation not permitted, 取消链接

react-native - 位于 "node_modules/web3-eth-accounts/src/index.js"的包试图导入 Node 标准库模块 "crypto"

javascript - React Native 选项卡导航显示问题

javascript - WebStorm 调试器在断点处将 React 组件内的局部变量视为 'undefined',尽管它有一个值

reactjs - 它的返回类型 'Element | undefined' 不是一个有效的 JSX 元素。类型 'undefined' 不可分配给类型 'Element | null'

javascript - 触发缓存以确保数据正确问题 - swr hook - next.js (使用 typescript )

ios - 应用程序在未从 Xcode 运行时自动关闭

android - FontFamily React Native App 使用设备自定义字体覆盖(三星和 Oppo)