using async function inside of functional component

Open
#2,897 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
frontend, web-dev

Research direction

Use the MyFC example as the reproduction entry point and consult the linked Stencil documentation before tracing functional-component rendering. The issue names no source file or test; done means confirming that a stateful web component renders a functional component containing the shown async fetch logic, with a regression check in the appropriate existing test location.

Written by the indexing model from the issue text.

Description

Feature: Want this? Upvote it!

Stencil version:

 @stencil/core@<version>

I'm submitting a:

[ ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

using async inside of functional component causes the functional component not render
Expected behavior:

statefull web components should render stateless functional components that has async functions in them.
Steps to reproduce:

use of async function inside of functional compoent

Related code:

export const MyFC = (props, children) => {
  let data;
  async function myAsyncFunc() {
    data = await fetch(props.url);
  }
  myAsyncFunc();
  return (
    <div>
      {data} {children}
    </div>
  );
};```

**Other information:**
<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->
Dominant language
TypeScript
Stars
13.1k
Forks
855
Avg merge
4h 7m
Merged PRs (30d)
44

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stenciljs/core

All issues in stenciljs/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.