Support Asynchronous Components
See original GitHub issueInspired 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
- Async rendering support
- Caching of ^ so subsequent renders are immediately resolved
- 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:
- Created 7 years ago
- Reactions:3
- Comments:18 (11 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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
?I would like to suggest to add the ability for
componentWillMount
andcomponentWillReceiveProps
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