-
Notifications
You must be signed in to change notification settings - Fork 40
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
Confusion about whenComponentsReady() #200
Comments
So you are right, on SSR that means every possible chunk. Technically you should
Probably the problem is not with Let's not guess. Is there any way to provide a little more details on how you use imported, so I could help you resolve this issue? |
I don't currently import this autogenerated file on the server side. I just looked over the documentation/examples again and it doesn't seem to be used on the server side there, only the client side. Should it be imported? That would explain how I can probably prune down my current project to a simple repro, it would take a little bit of work though. Maybe we can try a couple follow-up questions first? FWIW I'm using |
(In particular, I notice that the example at Update: I tried adding the import you mentioned like this: /* In server/ssr.tsx */
const imported = await import("../app/imported");
await whenComponentsReady();
await getDataFromTree(app); but this actually caused a weird error ( |
So the error is happening due to "loading" of components referred via |
Ah, that helped, thanks! Dev mode helped me find 2 different NPM dependencies that don't seem to behave well in SSR. I'll have to dig into why that is separately. I think the main remaining request for this issue would be to include information about |
😅 very serious issue |
I'm experiencing several points of confusion over the
whenComponentsReady()
function and how to use it.First of all, the README seems to be out of date. It indicates that a version of the function is exported from both the server-side API and client-side API at
react-imported-component/server
andreact-imported-component/boot
respectively. However, the former export doesn't seem to exist. A version is exported from the main packagereact-imported-component
. The two exported versions appear to be identical.The documentation for the server side says the returned promise will be resolved "when all components are loaded." I'm confused about what "all" means here -- does it mean every possible chunk? Should it therefore be called once on server startup and then never again, or should it be called on each request handler?
I'm trying to use it in conjuction with the Apollo GraphQL library, which has a function
getDataFromTree
which is meant to gather all the GraphQL queries needed by the tree. I tried puttingwhenComponentsReady
before it like this:However, I always get the following error message on the first request served by my server:
The log statements allow me to confirm this error message is happening while
getDataFromTree
is running. The fact that this happens is messing up the server-side render because some of the GraphQL queries are missed.I've tried sprinkling
await whenComponentsReady()
calls in various other places but no luck. I'm also confused becausewhenComponentsReady()
doesn't seem to be used in any of the examples in this repo.Any help would be much appreciated!
The text was updated successfully, but these errors were encountered: