Тёмный

😲 I Was WRONG About Next.js Client Components 

Dave Gray
Подписаться 323 тыс.
Просмотров 31 тыс.
50% 1

😲 I Was WRONG About Next.js Client Components
#nextjs #nextjs13 #reaction
💖 Support me on Patreon ➜ / davegray
💻 Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
🚀 Discord ➜ / discord
👇 Follow Me On Social Media:
GitHub: github.com/gitdagray
X: / yesdavidgray
LinkedIn: / davidagray
Blog: www.davegray.codes/

Опубликовано:

 

2 сен 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 40   
@lifealliancegroup
@lifealliancegroup 10 месяцев назад
Thanks for the crystal clear and fluid explanation
@fallen_turbo
@fallen_turbo 10 месяцев назад
The Title definetly gave me a mini heart attack, you definetly aren't wrong, its just a mishap in understanding. Your Next 13 playlist definetly taught me well.
@snivels
@snivels 10 месяцев назад
What if you pass a ServerComponent as a prop other than children? Will it still be a server component?
@reduxToolkit
@reduxToolkit 10 месяцев назад
Also curious about this
@robertsandiford6223
@robertsandiford6223 10 месяцев назад
Why wouldn't it be?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
Yes, referencing the docs "You can pass Server Components as a prop to a Client Component." Docs link: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props
@ROYAL-THUNDER
@ROYAL-THUNDER 9 месяцев назад
So if i use import statement in a use-client component, it'll be a child of comp and rendered on client. But if i pass it as prop, it's a server components? That's cool, I'm just blurred a lil about that
@funkdefied1
@funkdefied1 4 месяца назад
I was wrestling with this exact paradox this week. Thank you!
@slahomar1497
@slahomar1497 9 месяцев назад
What if I wrapped all my components with Context React >> Client Component ? Will all the children(and in this case all components) be clients components
@user-th7tj2xi5y
@user-th7tj2xi5y 10 месяцев назад
thx for video! which means, if i import server component in client component, it will be treated as client component but if i give server component as prop to client component, it will be still server component am i right?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
I'd say _do not import a server component into a client component_ . Some server code (Node.js) won't run in the client.
@rifwann
@rifwann 10 месяцев назад
I might need practical examples. If theres a form filled by server props then it could be passed to client and i could modify it changing nothing from the server. Is that right? Might need correction..
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
A form should be a client component for interaction. It would be strange to create a form server-side that was prefilled. Why would you need the form at that point? That said, quoting the docs "You can pass Server Components as a prop to a Client Component." Reference: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props
@rifwann
@rifwann 10 месяцев назад
@@DaveGrayTeachesCode maybe saved draft.. i honestly dont know what im saying so forget it. Also havent finished your next tutorial..
@dealloc
@dealloc 10 месяцев назад
It says Server and Client _modules_, not Server and Client _components_. Quite a distinction. Modules boundaries are defined as files en ES Modules (and in turn by Next.js) The key word is _modules_.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
I'm referring to _components_ as the docs do: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#interleaving-server-and-client-components ..not sure what you are looking at 👀
@dealloc
@dealloc 10 месяцев назад
​@@DaveGrayTeachesCode Ok maybe the confusion is regarding "including child components". What they mean here is any imported component module that are then referenced directly inside the client component, those whether those have "use client" or not, they will be imported as client-side. But essentially the missing part here is that you cannot import a Server Components module into Child Component module, and therefore have inverse it.
@austincodes
@austincodes 10 месяцев назад
Interesting 🤔
@thimerlanmatyakubov8940
@thimerlanmatyakubov8940 10 месяцев назад
I think u should create new full video about this error :?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
Maybe so - it isn't a correction for another video, but I think it could be a common misconception.
@thimerlanmatyakubov8940
@thimerlanmatyakubov8940 10 месяцев назад
@@DaveGrayTeachesCode SAME HERE
@afuwapedoyinsola844
@afuwapedoyinsola844 10 месяцев назад
Problem I had with this was positioning the server slots since they come in as children
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
You are not limited to {children}. See the docs examples: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props
@afuwapedoyinsola844
@afuwapedoyinsola844 10 месяцев назад
Thanks Dave!! Though could I maybe map the prop in a situation where I’m passing multiple server components so I can get each individually
@jellyfish1772
@jellyfish1772 10 месяцев назад
Haha i knew this before you😛😛😛
@sayedulkrm
@sayedulkrm 10 месяцев назад
Can anyone tell me what's in short? If i wrap my children with providers, will that still be a client component?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
No. Using a provider will not make all children client components. If this short video did not explain well enough, please reference the docs here: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props
@sayedulkrm
@sayedulkrm 10 месяцев назад
@@DaveGrayTeachesCode thank you so much. So if I use Redux toolkit and wrap my children then it won't make it "client" components
@beloaded3736
@beloaded3736 10 месяцев назад
Thanks Mr Gray
@minhhieple6483
@minhhieple6483 10 месяцев назад
That mean, You can't import Server Component into Client Component but, Server Component can be child of Client Component, right ?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
Yes. Reference: nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props
@pablom8854
@pablom8854 9 месяцев назад
is this just an app router thing? i'm new to nextjs
@DaveGrayTeachesCode
@DaveGrayTeachesCode 9 месяцев назад
Not specifically an app router thing. Next.js is constantly updated but this is a key to how Next.js handles server and client components.
@thedelanyo
@thedelanyo 9 месяцев назад
Reactjs is way too complex
@RegalWK
@RegalWK 10 месяцев назад
Why removing my comments :/
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
I didn't, but sometimes RU-vid automatically does.
@RegalWK
@RegalWK 10 месяцев назад
@@DaveGrayTeachesCode sureee
@erkintek
@erkintek 10 месяцев назад
nextjs is very dangerous,
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 месяцев назад
This does not mean that server code will be seen in the browser. I do not see a danger.
@erkintek
@erkintek 10 месяцев назад
@@DaveGrayTeachesCode wrong choice of word. I want to mean they are constantly changing, many things are not obvious, hidden in somewhere. It's normal because they are experimenting.
Далее
The Story of Next.js
12:13
Просмотров 555 тыс.
СДЕЛАЛА БРЕКЕТЫ ДОМА
01:01
Просмотров 1 млн
Don't Make These Next.js Mistakes
13:01
Просмотров 21 тыс.
Next.js Server Actions...  5 awesome things you can do
7:51
Pure React vs Next.js | What’s Happening in React?
12:23
10 common mistakes with the Next.js App Router
20:37
Просмотров 194 тыс.
State Managers Are Making Your Code Worse In React
13:33
Next.JS 13 Server and Client Components in 4 Minutes
4:21
React Server Components Change Everything
15:48
Просмотров 194 тыс.
The Problem with Next.js
9:52
Просмотров 45 тыс.