javascript - require ('react-native' ).NativeModules 是一个空对象

标签 javascript react-native npm import

在我的项目中使用的其中一个 node_modules 中,文件顶部显示:

let RNRandomBytes = require('react-native').NativeModules.RNRandomBytes

不幸的是,require('react-native').NativeModules 似乎是一个空对象 {}。我该如何从这里开始?

我尝试使用的包是:'react-native-secure-randombytes'。

如果有人对此有经验,我将不胜感激。

谢谢

最佳答案

您可以使用这种方式,可能对您有帮助

import {NativeModules} from 'react-native';

关于javascript - require ('react-native' ).NativeModules 是一个空对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48287950/

相关文章:

javascript - 如何在鼠标悬停时交换图像并在鼠标移出时交换回原始图像?

javascript - 无法编译 - Expo Web - 安装 UI-Kitten 后

ios - 如何使用 .fetch 函数在 react-native 中使 API 调用与 IPV6 兼容?

javascript - 无法安装 jest

javascript - 如何在此代码中使用断线?

javascript - Angular 平移显示键

android - 异步调用期间的 TouchableOpacity block #Performance React-native

node.js - Node : no response to NPM install

node.js - 有没有办法在不从本地驱动器打开每个项目的情况下删除所有 node_module?

javascript - D3.js 和 Dragdealer JS