React native - undefined is not an object (evaluating '_bip.default.generateMnemonic')

325 views Asked by At

I'm building a mobile application and I need to generate a passphrase using bip39. At first, when I installed the package from npm I got missing dependencies error concerning assert, events, stream and buffer. I installed the mentioned packages and I got the following error when I try to use bip39 library in my code :

undefined is not an object (evaluating '_bip.default.generateMnemonic') at components/newAccount.jsx:8:23 in handleSubmit at components/newAccount.jsx:6:23 in handleSubmit at node_modules/react-native/Libraries/Pressability/Pressability.js:697:17 in _performTransitionSideEffects at node_modules/react-native/Libraries/Pressability/Pressability.js:634:6 in _receiveSignal at node_modules/react-native/Libraries/Pressability/Pressability.js:528:8 in responderEventHandlers.onResponderRelease

Here is the code implementation :

const handleSubmit = async () => {
try {
  let seed = await bip39.generateMnemonic(256) // default to 128
  console.log(seed)
  return seed
} catch(e) {
  console.log(e)

}
navigation.navigate("Passphrase")
}

I also tried to use react-native-bip39 but no luck, I received a similar error

P.S : The application was created with Expo cli.

0

There are 0 answers