recommended way to asynchronously fetch data for render call?
See original GitHub issueDescription
~In the constructor on the Bigger Example on the README, it shows to await this.renderComplete
, but await
can only be used inside of an async
function and the constructor function is not marked as async
. It seems that the spec doesn’t say anything about a class allowing asynchronous constructor functions.~ This was clarified below. I missed that the async
is declared in the click event function inside constructor.
At any rate, the readme doesn’t seem as clear about this, but what is the recommended way to asynchronously fetch data and use it in the _render
call?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:17 (3 by maintainers)
Top Results From Across the Web
How To Handle Async Data Loading, Lazy Loading, and Code ...
Step 1 — Loading Asynchronous Data with useEffect ... In this step, you'll use the useEffect Hook to load asynchronous data into a...
Read more >Declarative Data Fetching with React Async - Bits and Pieces
Following is a simple example of using <Async> component to fetch data. In the above example fetch API is used to perform the...
Read more >recommended way to asynchronously fetch data for render call?
The await is inside the event listener function, which is async. this.addEventListener('click', async (e) ...
Read more >Hierarchy of React Async Components and Fetching Data
First, we will fetch data into our application. In React,, there are two methods to get asynchronous data: The fetch API and the...
Read more >Fetching Asynchronous Data with React Hooks - Giorgio Polvara
Probably the most common use-case for asynchronous code is to fetch a single resource when the component mounts. We need this all the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See https://www.npmjs.com/package/@lit-labs/task
I discussed this with @mkay581 via slack and got some more information to help clarify an answer. In his context, he’s working with
iron-pages
to display content and only wants to request the data for a page when it is the active page. To do so he’s using code like so:In the
page-with-async-data-one
I’m suggesting he relies less onlit-element
and more on general JS to see something like the following manage his data:@pshihn Thanks for the clarification on the rendering system, it made explaining this part much easier. Hope this helps anyone else who runs into this issue.