Source:  Twitter logo

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

24 users liked answer #0dislike answer #024
Vincent D'amour profile pic
Vincent D'amour

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.

0 users liked answer #1dislike answer #10
wvicioso profile pic
wvicioso

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).