This is what I'm trying do in React-Native. Async functions are making calls to firebase.
async functionOne() {
asyncStuffHappens
}
functionTwo() {
this.functionOne();
}
this.functionOne();
is undefined. I'm not sure how to call an async function from another function.
Like this:
async functionOne() {
asyncStuffHappens
}
functionTwo() {
(async () => {
await this.functionOne();
})();
}
This is called an IIFE (Immediately-invoked function expression) . It's a function executed right after it's created
Like @lonesomeday said, this.functionOne()
is all I needed. My issue was I wasn't binding this
properly in the onPress of the TouchableOpacity I was calling it from.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.