require('react-native').NativeModules is a

2019-07-09 23:47发布

问题:

In one of the node_modules that I'm using in my project at the top of the file it says:

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

Unfortunately, it appears that require('react-native').NativeModules is an empty object {}. How can I proceed from here?

The package that I'm trying to use is: 'react-native-secure-randombytes'.

If anyone has experience with this I'd really appreciate it.

Thanks

回答1:

You can use this way may be it help you

import {NativeModules} from 'react-native';


回答2:

I would do this instead

let RNRandomBytes = require('react-native-secure-randombytes')

What you're doing means that it's part of the react-native module, which it is not.