-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
Update usage-next-13.mdx: BlitzProvider
as client component
#847
Conversation
@tordans is attempting to deploy a commit to the Blitz Team on Vercel. A member of the Team first needs to authorize it. |
@tordans I do not understand this, We can definitely use server components with blitz. You do not need to make all pages "use client" client components. I might have misunderstood your intention and I am looking at the issues referenced now. |
@@ -58,6 +57,8 @@ export const {withBlitz, BlitzProvider} = setupBlitzClient({ | |||
|
|||
```tsx | |||
// layout.ts | |||
'use client' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to learn how :-). The "Testcase" I described above shows the issue. Add/remove the "use client" and it works or doen't…
@@ -24,14 +24,13 @@ the following methods and hooks have been implemented to work in the new `app` d | |||
|
|||
#### Required changes {#required-changes} | |||
|
|||
Add the new `use client` directive to the following files: | |||
Add the new `use client` directive to **all** files in the include-tree below [`BlitzProvider`](https://blitzjs.com/docs/usage-next-13#blitz-provider), which is a client component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all
files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, that https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#unsupported-pattern-importing-server-components-into-client-components
You cannot import a Server Component into a Client Component
Results is a bad error message
Error: Unsupported Server Component type: undefined
One thing I did was to remove all barrel files from our project in order to work around this issue, as suggested in vercel/next.js#41940
(But in the end we added 'use client'
to all files (for now), just to get to a working version.)
My current understanding is: Since I cannot import server components into client components and I cannot audit every include, for the slot-workaround you mentioned, I have to add use client
to all files that are imported in other files.
The changes I propose here are wrong, I will close the PR. |
Theres is also the request for help at https://discord.com/channels/802917734999523368/1161576668863922176.
See also blitz-js/blitz#4232.
Change
My understanding is, that
BlitzProvider
is a client component and the way I understand the app directory means that everything below in the include-tree needs to be a client component as well.Testcase
Error