taxonomy icon indicating copy to clipboard operation
taxonomy copied to clipboard

'use client' at root

Open BryanAM opened this issue 1 year ago • 3 comments

I noticed at the root of the project in app/layout taxonomy imports the client component ThemeProvider and passes the rest of the children down through props. I'm new to Next.js but I see in the documentation, that "Once "use client" is defined in a file, all other modules imported into it, including child components, are considered part of the client bundle" Is this a non-issue since the children are only passed by prop?

Perhaps regardless of impact, it's necessary because createContext requires 'use client'.

BryanAM avatar May 05 '23 13:05 BryanAM

I don't know the answer, but ThemeProvider is a HOC so I do believe you have a good concern.

guifeliper avatar May 12 '23 20:05 guifeliper

"Once "use client" is defined in a file, all other modules imported into it, including child components, are considered part of the client bundle

As stated, child components are the ones that will be transformed into client components. What you pass in as children will not be affected. you might want to read this article https://www.developerway.com/posts/react-elements-children-parents

bryanprimus avatar May 21 '23 02:05 bryanprimus

@bryanltobing

Great article, this helps clear up my question. Thank you for sharing!

BryanAM avatar May 21 '23 15:05 BryanAM