-
Notifications
You must be signed in to change notification settings - Fork 36
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
registerApolloClient is not a function (Runtime error) #268
Comments
This would happen if you import Do you import |
Are you building for Edge functions? |
Sorry, don't get it. What is Edge functions? It's really small app, I use only next-intl and apollo client. |
Okay, obviously not :) I think we need to get back to my previous question: I see that you re-export |
No, I only use import from "@/configs" in Layout.tsx and MainIntro.tsx. And both of them don't use "use client". It's really strange, inside MainIntro.tsx i use FilterClient.tsx components and it's client component. |
Something seems to pull your server component file into client components here :/ Generally, Next.js build two independent versions of your app:
Internally, these import completely different files for the same So, if you call React itself does the same. If you |
Got it. It happens when I add "use client" on the Header.tsx file. Without this all works fine. Do you have any ideal how to solve it? |
Your You have to stop using these |
HM. I guess I catch the problem. Header.tsx works with "use client" when I remove from it. |
@phryneas You are right, another import solve it. import { Container } from "@/components/ui";
//import { Container } from "@/components"; |
Exactly that :) |
But why? =) This type of import isn't a mistake, it works, but not in the Next.js. |
Your I would really recommend that you never use |
A Client Component is never allowed to import from a file that contains a React Server Component, because that "makes it a Client Component". In some cases it's just a bundling error, in some cases it can even pose a security risk. |
Thanks for your help |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Hey there. This is a first time I'm using Next JS 14 and Apollo client. I've done ApolloProvider and apollo-client.ts like in the documentation.
In MainIntro I use an SSR request to preload the data that I use in the child component. The Header component must be client-side because I'm going to use hooks. As soon as I add "use client" to Header.tsx, I get the described error. Please help, below I post the component code and errors.
error
apollo-client.ts
apollo-wrapper.tsx
lauout.tsx
page.tsx
MainIntro.tsx
header.tsx
The text was updated successfully, but these errors were encountered: