Reputation: 1420
I'm trying to use this react-native library to do sha256 hashing. Here is my code:
import React, {Component} from 'react'
import { AppRegistry, Text, View} from 'react-native'
import {sha256} from 'react-native-sha256'
export default class CyrptoTest extends Component {
constructor(props){
super(props)
}
componentDidMount(){
sha256("test").then(hash => {
console.log(hash)
})
}
render(){
return(
<View style={{padding:30}}>
<Text>this is CryptoTest 1</Text>
</View>
)
}
}
I am getting this error: undefined is not an object (evaluating 'sha256lib.sha256')
I do not know why this is or how to fix this, any help is appreciated, thanks
PS: Before I did any of this I first ran this in the command line:
yarn add react-native-sha256
react-native link
Also to run the app in my emulator on my mac I do this:
react-native start
react-native run-ios
Upvotes: 3
Views: 2261
Reputation: 56
I had the same problem, in my case I was using the react native cli debug server host & port for device, it was solved with a ./gradlew clean and recompiling the app on the phone.
Upvotes: 1