preactjs / preact

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
https://preactjs.com
MIT License
36.59k stars 1.95k forks source link

Empty result of lazy component doubles next node #4079

Open aleksandrjet opened 1 year ago

aleksandrjet commented 1 year ago

I found a bug with empty result of lazy component. I could't fix it and opened pr with fallen test.

Perhaps this is not so easy to fix. Maybe add a notice to the documentation, that lazy component requires something to return (not null or empty fragment)?

JoviDeCroock commented 11 months ago

Hmm, yeah this would be indeed quite hard to fix as it seems a general issue with having no matching DOM for a given VNode during a suspended hydration, basically we want to match some kind of DOM to the suspended node while hydration is ongoing. We currently don't really have a way to see that the oldDom pointer has been consumed and that the future result of lazy will be a placeholder i.e. null