0

I have async fnction and 2 block of template, function called in render But instead of template I get objectPromise Why it happens and how fix it?

 async renderTabsDependOnStatusAccess() {
    if (true) {
        return this.renderTabsAfterLogin()
    } else {
        return this.renderTabsBeforeLogin()
    }
}

render() {
  return (
      <div class="navigation">
          ${this.renderTabsDependOnStatusAccess()}
      </div>
    );
}

2
  • 1
    Generally, you need to await the resolved value of a Promise (which is what an async function returns). However, it looks like there's no need for your function here to be async. Is there more to your implementation than you have shared? Commented Dec 22, 2020 at 16:09
  • Whatever React components you want to render, you could store as state somehow, and then render that state, rather than rendering whatever that function returns (it returns a promise, so React can't render that) Commented Dec 22, 2020 at 16:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.