RNRandomBytes - undefined is not an object (evaluating 'RNRandomBytes.randomBytes

Hi,

I’m working on an app at the moment that is going to use “react-native-secure-randombytes” and I assumed it would work with react-native and Expo.

So far I’ve installed the package using npm install --save react-native-secure-randombytes and I’ve also run rnpm link.

I’m currently getting the error “undefined is not an object(evaluating ‘RNRandomBytes.randomBytes’)”. I can see the .h and .m files in the directory of the npm module, but I’m not able to use it. If anyone can help with this I’d be really grateful.

Thanks

hi -

unfortunately, this library adds native code into a project and so you can’t just npm install it and use it. you’ll need to detach your expo project or find another way to do it with just JS.

You can make a feature request for adding this module or similar into Expo here:

This request seems somewhat similar to what you want. Crypto API | Voters | Expo

You can also use http://native.directory/ to check which libraries likely work with Expo and other platforms.

Hope that helps.

If I detach the project will the code I’ve already written just work? Or will I need to make changes? Just to confirm, do you mean do this https://docs.expo.io/versions/latest/guides/detach.html?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.