I have a function which I will generate SHA256 signature. But I cannot bring out the value from it.
Function Property:
timer = null
ScanCode_Change_Event = (e) => {
clearTimeout(this.timer);
this.timer = setTimeout(() => { this.triggerChange() }, 500);
}
triggerChange = async () => {
await this._onSendSignature();
}
_onSendSignature = async () => {
const BarcodeNo = this.state.BarcodeNo;
const valueToHash = MerchantKey + BarcodeNo + Amount.replace('.', '').replace(',', '');
sha256(valueToHash).then( hash => {
// This can show the signature
ToastAndroid.show('Signature: ' + hash, ToastAndroid.LONG, ToastAndroid.BOTTOM);
this.setState({
hashSignature: hash
})
})
// This cannot show the signature
ToastAndroid.show('Signature: ' + this.state.hashSignature, ToastAndroid.LONG, ToastAndroid.BOTTOM);
}
Render:
<Input style={{ color: 'brown' }}
placeholder='Scan Barcode'
placeholderTextColor='rgba(0, 0, 0, 0.3)'
autoFocus={true}
onChange={evt => this.ScanCode_Change_Event(evt)}
onChangeText={(BarcodeNo) => this.setState({ BarcodeNo})}>{this.state.BarcodeNo}</Input>
I'm currently lost of what is happening. BarcodeNo
can get the value in this.state
but .
I have try to add this._onSendSignature = this._onSendSignature.bind(this);
on constructor. Do I missed something?