-
-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Describe the bug
When rendering an asynchronous component using import { lazy } from "preact/compat"
, the rendering fails and throws an error.
The error is a promise, and when resolved, it resolves to the component that was lazy, causing weird glitches on the server.
To Reproduce
Steps to reproduce the behavior:
Follow instructions for the reproduction repository here.
Expected behavior
import { render } from "preact-render-to-string"
should return a promise that resolves to the whole rendered string.
Browser (please complete the following information):
- OS: [e.g. Windows 11]: Arch
- Browser [e.g. Chrome 108]: Chrome 108
Node (please complete the following information):
- Platform: [e.g. Node 18]: Node 19.3.0
- Package Manager [e.g. NPM 8.2.13]: NPM 8.19.2
- Package Version [e.g. 0.2.1]: 5.2.6
Additional context
It would be even better to have a different implementation in order to prevent implementing breaking changes with a function that would indeed account for lazy components ala ReactDOMServer.
import { renderToPromise, renderToStream } from "preact-render-to-string"
console.log(await renderToPromise(<Main />))
renderToStream(<Main />).pipe(process.stdout)