Reputation: 487
I have to send an codeActivation with my API after calling this codeActivation from asyncStorage so I use this code:
componentDidMount() {
AsyncStorage.getItem(CODEACTIVATION_STORED)
.then(code => {
this.setState({ codeActivation: code})
console.log('t2 ' + this.state.codeActivation); << output : t1 544875962
});
AsyncStorage.getItem(TOKEN_STORED)
.then(code => {
this.setState({ Token: code})
});
console.log('t1 ' + this.state.codeActivation); << output: t1
this.pwHash(); << where I use this.state.codeActivation
}
how to call pwHash after setting my codeActivation from asyncStorage in this.state.codeActivation ?
Upvotes: 0
Views: 63
Reputation: 1265
componentDidMount() {
setInterval(() => {
AsyncStorage.getItem(CODEACTIVATION_STORED)
.then(code => {
this.setState({ codeActivation: code})
console.log('t2 ' + this.state.codeActivation); << output : t1 544875962
});
AsyncStorage.getItem(TOKEN_STORED)
.then(code => {
this.setState({ Token: code})
console.log('t1 ' + this.state.codeActivation); << output: t1
this.pwHash(); << where I use this.state.codeActivation && this.state.token
});
}, 5000);
}
you can call it like this or you can just ignore setInterval()
if that is not you need.
Upvotes: 1