-
-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 17 + 18 support #718
Comments
Hey @apepper 👋, |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is not stale. React 17 is still not supported: loadable-components/package.json Lines 54 to 55 in 73b17fd
|
I use [email protected] and @loadable/[email protected]. They work well. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still relevant |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
1️⃣7️⃣ |
1️⃣8️⃣ |
Hey! Is it possible to let us know approximately date for the next release with React 17,18 support? Thanks) |
@abhisharkjangir No, it doesn't. The library is mostly dead for the last 2 years, except for a few fixes by @theKashey. |
Now that the React team has stopped recommending loadable-components in their docs, does anyone know what the official blessed setup is? With React.lazy, webpack, server-side rendering, and all? |
React 18 is a frontend library, it can't collect a list of dynamic imports that were |
I'll just leave Dan's code sandbox here, from a comment where he said that React.lazy "just works" now. Perhaps this is what the recommended way of doing this now is. |
There is no recommended way of doing this and the majority of libraries(or react itself) are not working one way or another due to different reasons.
|
@abhisharkjangir I've created an example of usign |
@vaukalak Thanks, I'll try if it works for me or not. |
React 18 with Suspense would be better if chunkextractor could have a reset method. Then we could use a custom writable in renderToPipeableStream that wrote the discovered components script tags as we render. But loadableReady in the client cannot be used anymore so maybe write some script tags that say which modules will be loaded from those async script tags so we don’t try to refetch those during hydration. If I understand all this correctly. https://github.com/brillout/react-streaming#injecttostream |
Hello, I see there is a next release tag on this issue. Is there a roadmap or a release date scheduled? Any branch for development? Thanks a lot for this library! |
So decided to not use https://github.com/brillout/react-streaming#injecttostream Instead I did this let didError = false;
let shellReady = false;
class LoadableWritable extends Writable {
constructor(writable) {
super();
this._writable = writable;
}
_write(chunk, encoding, callback) {
// This should pick up any new link tags that hasn't been previously
// written to this stream.
if (shellReady) {
}
// Finally write whatever React tried to write.
this._writable.write(chunk, encoding, callback);
}
end() {
this._writable.end()
}
flush() {
if (typeof this._writable.flush === 'function') {
this._writable.flush();
}
}
}
const writeable = new LoadableWritable(res)
const stream = renderToPipeableStream(<Html assets={{}}><App /></Html>,
{
onShellReady() {
// The content above all Suspense boundaries is ready.
// If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
shellReady = true;
stream.pipe(writeable);
}) https://github.com/fivethreeo/loadable-components-react-18 Will try adding loadabe-components soon Clone and run pnpm i
pnpm start |
Tried adding loadable components with streaming react and suspense. Did not work. |
Added support for streaming rendering with suspense here. |
Any outlook for React 18 support in the near future? |
There is "real" React 18 support in works - #923, but I don't see any reason not to update package dependencies right away... |
I agree - people can upgrade to 18 and get the current code to work, while deferring the use of |
v
|
Did this happen? I don't see a v 5.15.3 in the releases and v5.16.0 says |
Any idea how we can get React 18 and Loadable to work correctly? Just some general steps / direction would be greatly appreciated. |
We are using Loadable just fine in React 18, what's the issue? We (IBM) are currently using the latest loadable-components with React 18.2 and Loadable works fine (we are doing as explained above - rendering the App porting using |
Any reason why you prefer this over React.lazy? |
SSR. We use Loadable since React16 and needed it for server side rendering. For the client side, Lazy is fine. Obviously React has this new approach for SSR in 18 with Suspense and Server Only components but this is still early and they apparently let the likes of Next.js and Remix to take the lead and define what SSR should look like with Suspense. We are waiting for that dust to settle and continuing to use Loadable as explained above. |
I just wanted to put it out there that React.lazy works fine with SSR without any requirement for Next, or server components, or anything like that. I'm using it with my custom (i.e. non-next) SSR setup. There's a minimal demo linked to in a comment above. |
Unfortunately using Lazy, or better to say - relying on Suspense does not work in many case. That's it - your app is expected to be "dead" until hydration is complete and This is not a "code splitting" library, this is "code tracking" library. That something Lazy does not do |
Can you share a basic example in code? Really curious about this part: "rendering the App porting using |
Unfortunately there is too much code in too many places to distill into a simple example. Let me try in words:
Visually, it looks great - normally the first render is in under 200ms, and entire page is done rendering in under 500ms, even with multiple API calls done to fetch necessary metadata. While we are watching Server Only Components and Suspense story evolve, we don't want to commit to Next.js or Remix to get them. |
@dglozic is that an internal company solution or was is based on an existing blueprint? I've been looking into using |
It is internal, yes. But it is not hard to reproduce. It is also kind of interim because some proposals to support stats with streaming didn't yet make it into loadable-components (hence the initial render to a buffer to get the stats computed the old way). I keep hoping that @fivethreeo has put together would get merged :-). |
Gonna take a look at that example. Thank you! |
Currently
@loadable/component
only supports react 16 is supported:loadable-components/package.json
Lines 54 to 55 in cba6cab
It would be great, if it would also support React 17 and the latest React 18.
The text was updated successfully, but these errors were encountered: