Ozgur
Ozgur

Reputation: 41

Calling async function from custom flatlist view

I am trying to call an async function in a customer flatlist view, but I am get errors caused by using await in the custom flatlist view:

async _customFlatlistView(item){
    promise = await SomeFunction(); 

    promise2 = await SomeOtherFunction();
}

Upvotes: 0

Views: 152

Answers (2)

Rishav Kumar
Rishav Kumar

Reputation: 5460

The await keyword can only be used in adding the async keyword to the method signature:

    async _customFlatlistView(item){
        promise = await SomeFunction(); 

        promise2 = await SomeOtherFunction();
    }

Upvotes: 0

Zaytri
Zaytri

Reputation: 2574

await can only be used in async functions

_customFlatlistView = async item => {
  promise = await SomeFunction()
  promise2 = await SomeOtherFunction()
}

Upvotes: 1

Related Questions