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>
    );
}

Bob
  • 1,004
  • 9
  • 12
alex
  • 137
  • 1
  • 8
  • 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? – old greg Dec 22 '20 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) – TKoL Dec 22 '20 at 16:16

0 Answers0