Skip to content

Props must be serializable for components in "use client" file #46795

Answered by shuding
ryandotelliott asked this question in Help
Discussion options

You must be logged in to vote

You should remove "use client" from child.tsx.

A "use client" directive means that component is a boundary between server and client components. Since parent.tsx is already inside the client boundary, everything imported will be client components already. And that includes child.tsx.

Why there's this warning? Since it's a boundary, you can potentially use it in a server component. However it's not allowed to have props that can't be serialized in that case. If you import child.tsx and render it inside a server component, there's no way to pass a function as the prop.

So this warning also suggests that you should not add "use client" to every client component, but only those boundaries tha…

Replies: 14 comments 33 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@shriharip
Comment options

Comment options

You must be logged in to vote
18 replies
@eluchsinger
Comment options

@OrhanTozan
Comment options

@2-fly-4-ai
Comment options

@preitinger
Comment options

@alexbaileyuk
Comment options

Answer selected by ryandotelliott
Comment options

You must be logged in to vote
5 replies
@hungcrush
Comment options

@P233
Comment options

@Hachikoi-the-creator
Comment options

@DaehoKwag
Comment options

@juliansommer
Comment options

Comment options

You must be logged in to vote
1 reply
@panddr
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@JSONRice
Comment options

Comment options

You must be logged in to vote
2 replies
@jrnxf
Comment options

@joeshub
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ARBS-23
Comment options

@kkirby
Comment options

Comment options

You must be logged in to vote
1 reply
@SamJbori
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@hainguyents13
Comment options

@mcfry
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet