-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
null is not an object (evaluating RNRandomBytes.seed) #40
Comments
Did you found a solution for this? |
No unfortunately. I ended up just using the native crypto libraries in Android to get it to work. Very frustrating issue though. |
@JUDOKICK I'm having the same issue, please help is there any workaround? |
Using Java and linking the two with an ejected version of my app. There is no fix for this. React-Native won't support new NodeJs libraries. This used to work on older versions. But now all the libraries that end up needing the NodeJs libraries use newer versions. Unless you feel like digging through your dependencies and locking each specific version just to get this to work. I highly suggest ejecting and using the native java/swift libraries. |
ok, thanks may I know how can I use native libraries? Can you share a code example like you did it would be really helpful for me? |
Unfortunately, you're going to have to look on your own for examples on how
to do that as it's different for every implementation.
…On Fri, 1 May 2020, 11:56 Yasir Shah, ***@***.***> wrote:
ok, thanks may I know how can I use native libraries? Please help
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AELX7GYLUNWOBWD3A753LBLRPKTFXANCNFSM4KSRSW2A>
.
|
I found a temporary solution to this problem To add missing native module you need to manually add specific files from this repo to your project For example, if you need this to work on Android, you have to copy two files in android/src/main/java/com/bitgo/randombytes/ And after that, in debug mode I was able to see that native module is not null and everything works fine |
In my case, I had react-native-randombytes installed. Maybe you did the |
I think expo is the problem here. I tried setting it up with this boilerplate where you can specify if you want to use expo for your project or not. Without expo it is working fine and with expo it fails with this error. Just wanted to leave this comment in case it helps anyone pin down the issue. |
This was a problem for me while working with expo SDK and I needed rn-nodeify:
I think that by running the 3rd command with expo and not with rn-nodeify it linked the needed dependencies. Update: It created another problem, so didn't fix it. I think metro config fixed the problem. |
I have an expo application, I added the import statement to my code and suddenly faced this error ? is there anyway to make it work with expo ? |
I fixed it by opening the file explorer and explicitly searched for all the files inside my project that contain "RNRandomBytes.seed" text in them and then, inside all of the file indexes found, I just replace the init() function with this code:
|
I still have this issue with expo |
Can you elaborate on exactly how this fixed your issue please? I have the same error and tried this hacky approach only to have the app fail in a similar fashion - "o.default.randomBytes is not a function" |
Does your app not need RNRandomBytes? Do you do any crypto operations in your app? I am struggling to get this fixed. |
You are a god among men |
I am currently unable to use react-native-crypto because randombytes throws this null error.
I am using an ejected Expo, SDK35, and all steps followed from react-native-crypto
I have linked correctly, used rn-nodeify and imported the shim file and still it is not working.
I have tried possibly all combinations of steps and procedures for installations and none of them seem to work for the latest expo/react-native sdks.
It has to do with this section of code
let sjcl = require('sjcl')
`let RNRandomBytes = require('react-native').NativeModules.RNRandomBytes
function noop () {}
function toBuffer (nativeStr) {
return new Buffer(nativeStr, 'base64')
}
function init () {
if (RNRandomBytes.seed) {
let seedBuffer = toBuffer(RNRandomBytes.seed)
addEntropy(seedBuffer)
} else {
seedSJCL()
}
}
The error is line 15
if (RNRandomBytes.seed)` meaning that it never gets initialized somehowThe text was updated successfully, but these errors were encountered: