How to wait for a method to end in JS?

Asked

Viewed 1,081 times

0

Hello,

I can’t get JS to wait for the method to finish the execution before showing the return, someone can help me?

Method:

getValor(jogador) {
        const id_grupo = this.props.grupoSelected.id;
        if (jogador.financeiro) {
            const arrayFinanceiro = Object.keys(jogador.financeiro);
            if (arrayFinanceiro) {
                arrayFinanceiro.forEach((grupoKey) => {
                    if (grupoKey === id_grupo) {
                        return jogador.financeiro[grupoKey];
                    }
                });
            } else return 0;
        } else return 0;
    }

JSX:

<Text>{ this.getValor(jogador) }</Text>

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.