Update to React 18.3.1 and use RenderToPipeableStream in the SSR part
I've been investigating lately the use of Suspense in Volto itself. Since we are not using RenderToPipeableStream in the SSR part, our build is not fully compatible with Suspense. This addresses that and upgrades to latest React 18.3.1. I am updating @loadable/component to latest version too. It seems that the three of them have not yet fully support for working together, since @loadable/component is not maintained anymore, so there's a small drawback.
If using Suspense and React.lazy together (sometimes, not always since it's a timing issue) you get this error:
react-dom.development.js:20701 Uncaught Error: The server did not finish this Suspense boundary: The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server
at updateDehydratedSuspenseComponent (react-dom.development.js:20701:1)
at updateSuspenseComponent (react-dom.development.js:20401:1)
at beginWork (react-dom.development.js:21663:1)
at beginWork$1 (react-dom.development.js:27465:1)
at performUnitOfWork (react-dom.development.js:26596:1)
at workLoopSync (react-dom.development.js:26505:1)
at renderRootSync (react-dom.development.js:26473:1)
at performConcurrentWorkOnRoot (react-dom.development.js:25777:1)
at workLoop (scheduler.development.js:266:1)
at flushWork (scheduler.development.js:239:1)
at MessagePort.performWorkUntilDeadline (scheduler.development.js:533:1)
Because how loadable components behave... On the other side, the SSR renders well (eg. the suspense boundary is observed, and it does not render until it's resolved), and the response returned in SSR mode (eg. no JS involved, SEO mode).
BUT this (misleading) error is shown, ONLY sometimes...
Anyways, I would not use React.lazy in core, continuing using loadables instead, but state that Volto support Suspense in add-ons and projects, if needed. So, I would push for this one.
Also, it would be needed to update the add-ons... UNFORTUNATELY, all are pinned to use as peer 18.2.0 especifically.
Ok, acceptance tests looks like a christmas tree 🎄 😰