question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Asynchronous Components

See original GitHub issue

Inspired by https://twitter.com/youyuxi/status/824659082816716802

It’d be great if we could do the same with Preact. Looking forward to a discussion about what would it take to add support. Off the top of my head, this would possibly need

  1. Async rendering support
  2. Caching of ^ so subsequent renders are immediately resolved
  3. Update h to support Promises as children

A common argument against this would be to have this in userland code, however there are legitimate cases where having this baked into the framework itself would strongly encourage developers to start using code-splitting, which I think fits into Preact’s goals of performance and min size.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
robertknightcommented, Mar 15, 2019

Given that React now has an official API for loading components lazily (Suspense), perhaps we should close this issue in favour of one for implementing an API compatible with React.lazy?

3reactions
Satyamcommented, Mar 29, 2017

I would like to suggest to add the ability for componentWillMount and componentWillReceiveProps to return a Promise, in which case the rendering would be delayed until the Promise is resolved. I meant to offer a working example and I modified setComponentProps and tried to make some examples to show it working but, unfortunately, due to my lack of deep knowledge of Preact, failed to make it work.

The Readme file on the example code explains what I tried to do and how to use it.

The existing tests on the modified Preact run fine, so the change is backward compatible.

I am sorry I am new to Preact, I hoped I could be more helpful.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async components
Such a component is called an async component. An async component can render its state in a meaningful way like any other component,...
Read more >
How to: Use Components That Support the Event-based ...
Using asynchronous methods on a class that supports the Event-based Asynchronous Pattern Overview can be as simple as attaching an event handler ...
Read more >
Async Components
Asynchronous operations inevitably involve loading and error states - defineAsyncComponent() supports handling these states via advanced options:.
Read more >
BusinessWorks - Asynchronous Process Component
As mentioned in the previous section, the backend interface is asynchronous so when the Process Component sends a request to the backend application,...
Read more >
Asynchronous HST Components and Containers
Introduction · Configure an HST Component to be Rendered Asynchronously · Supported Asynchronous Modes · Restrictions · Async Components Nested Below Async ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found