Context with Next.js 14 - Course part 18

  Рет қаралды 27,147

Codewithguillaume

Codewithguillaume

Күн бұрын

Пікірлер: 71
@djribs
@djribs 7 ай бұрын
I've watched or read a BILLION tutorials on Context API in React and this is the only one that made enough sense to get it working and more importantly to understand it, while converting it to my use case! You're a champion!
@codewithguillaume
@codewithguillaume 7 ай бұрын
Oh dude your message means so much to me… thanks. If you want to go deeper I am launching a plat for soon : thedevelopercourse.com ! Best
@djribs
@djribs 6 ай бұрын
I spoke too soon! It seems I've done something incorrectly because no matter where I try to set the context, the default value never changes when trying to read it. I was of the understanding that wrapping the RootLayout of the app in the context as you've described in your video would allow it to be consumed by all components and their children since everything is a descendant of RootLayout. Any idea what could be wrong?
@djribs
@djribs 6 ай бұрын
Turns out it was working after all! I wasn't actually using the context value yet. I was trying to console.log its value to confirm it worked, which kept showing the default value. When I actually used the value in another component it worked. It seems console.log always shows the default value, though I have no idea why!
@Juajuaa18
@Juajuaa18 6 ай бұрын
Correct me if I'm wrong (I'm learning server side components). If you 'use client' on root layout, then your whole application will be client side only and you won't be able to use any server side components or rendering, right?
@mohamedtsx
@mohamedtsx 6 ай бұрын
Your explanation is great! You start with a single piece, and if it's okay, let's see another one. Thanks a lot!
@codewithguillaume
@codewithguillaume 6 ай бұрын
Thanks my friend ! Discord if you want to join dub.sh/codewithg-discord
@zhongyou916
@zhongyou916 6 ай бұрын
Your tutorial is very easy to understand. I've read many other articles and couldn't understand. thanks a lot.
@ryumarukurozaki7245
@ryumarukurozaki7245 7 ай бұрын
You're the best! this helped me for my personal project! keep making videos!
@codewithguillaume
@codewithguillaume 7 ай бұрын
Yesssss !
@polidahiya9024
@polidahiya9024 6 ай бұрын
using context api like this i don't think there is any use of using next js over react , now the whole application is a client component
@jordanboutrois1584
@jordanboutrois1584 8 ай бұрын
Hi, I'm asking a question, you're declaring your context provider near to the root of application, so Is each children which passed into Provider are client components? and therefore Doesn't this prevent us from taking advantage of the server components? (Thanks for the video, great job)
@djribs
@djribs 7 ай бұрын
Look up "interleaving" in React. The short answer is no, they all won't become client components from putting context at the root.
@staromofficial
@staromofficial 5 ай бұрын
no, read nextjs docs, they have explained it, when u wrap with cleint componet it does not make its childs a cleint component . They still treated or used as server component
@DhaouJawhar
@DhaouJawhar 5 ай бұрын
just what I needed, thank you so much!! ♥
@lukeparker6026
@lukeparker6026 6 ай бұрын
Thank you for creating this video!
@codewithguillaume
@codewithguillaume 6 ай бұрын
No problem Luke I hope you find your responses
@ajaljose2690
@ajaljose2690 6 ай бұрын
At last something that worked for me. thank you :)
@codewithguillaume
@codewithguillaume 6 ай бұрын
Nice join my discord 😉
@memoryclips.moment
@memoryclips.moment 3 ай бұрын
I relly like the way he teach it can't be easier than this tnx 👍
@felipeconceicao4465
@felipeconceicao4465 5 ай бұрын
Amazing video, thank you so much. Best wishes from Brazil
@Dana-Baiardi
@Dana-Baiardi 8 ай бұрын
you did it so easy!!! :) loved it! It worked fabulous!!
@codewithguillaume
@codewithguillaume 8 ай бұрын
Amazing! Glad it helped you 😉👍
@DePhpBug
@DePhpBug 2 ай бұрын
Thanks the author of this youtuber , the content helps me alot. Don't stop producing great content , keep it up (y)
@IbrahimSowunmi-sp4qs
@IbrahimSowunmi-sp4qs 4 ай бұрын
Huge video, thank you!
@rogeriolimas
@rogeriolimas 5 ай бұрын
Great video! Thank you!
@TarasDyda
@TarasDyda 4 ай бұрын
What is the use of NextJS if it renders the content on the client side?
@tekskilldev8310
@tekskilldev8310 6 ай бұрын
Beautifully explained. However, I have done the same i.e. providing context to all components(sharing provider) by following next ui method. That method is install nextui and create a provider.js file within the app folder. This provider works as wrapper which is then imported in the layout.js file wrapping all components in the layout including navbar you create within the layout file. I think this eliminates the need of src folder and need to use useContext function and all other context creation. See if you agree?
@ivannavas8620
@ivannavas8620 5 ай бұрын
Thanks so much, just the video i needed 👏
@guvenfazli
@guvenfazli 5 ай бұрын
Thank you so much, i finally got it.
@mtspivato
@mtspivato 5 ай бұрын
great content!
@kmplus360
@kmplus360 8 ай бұрын
I am a new subscriber. Thank you very much for the content
@codewithguillaume
@codewithguillaume 8 ай бұрын
Welcome and thank you my friend !
@sergio058-pb6hf
@sergio058-pb6hf 11 ай бұрын
just what I needed, thank you so much!!
@techug2719
@techug2719 5 ай бұрын
So, my question is on the metadata, i export my metadata from the root layout.tsx, making the root layout client doesn't allow me to export this metadata, how would you go about this?
@Xurshid_Yoldoshev
@Xurshid_Yoldoshev 4 ай бұрын
thanks from uzbekistan
@codewithguillaume
@codewithguillaume 4 ай бұрын
Thanks man !
@Ziad-Al
@Ziad-Al 6 ай бұрын
great explanation, thank you, how about if we want to use the name and useName inside a page which is server component or simply not declared as "use client"?
@Sniksax
@Sniksax 10 ай бұрын
Merci Guillaume, t'es le meilleur !
@codewithguillaume
@codewithguillaume 10 ай бұрын
Merci Mohamed !
@violinsheetmusicblog
@violinsheetmusicblog 7 ай бұрын
Why do you define the state twice? Once in useState() and another time in createContext()? Seems redundant, not sure why it is necessary Oh I guess it's because AppContext can be used on its own without the component
@codewithguillaume
@codewithguillaume 7 ай бұрын
Yes
@LorenzoSemorile
@LorenzoSemorile 8 ай бұрын
Great video. Thanks so much. When i try to use the contextProvider in a server component, my app goes in a infinite loop. Any suggest?
@pauliusm2735
@pauliusm2735 8 ай бұрын
God bless and ty!
@pnh.2314
@pnh.2314 7 ай бұрын
Best explained 🤌
@samuelizevbizua
@samuelizevbizua 10 ай бұрын
God bless you brother. Really helped
@codewithguillaume
@codewithguillaume 10 ай бұрын
Thanks my friend
@altafansari752
@altafansari752 7 ай бұрын
But if you wrap the server side component inside the Client component then all the server components serve as client components?
@Nscb1947
@Nscb1947 7 ай бұрын
no
@Juajuaa18
@Juajuaa18 6 ай бұрын
@@Nscb1947 why not? if root layout is client component, then all of it's children are client too. Am I wrong? Please correct me if I am, I'm learning about server side components.
@IAmMrLiverpool
@IAmMrLiverpool 8 ай бұрын
Hi, thx for your work. Can I ask which theme you use for vscode (and which icons). thanks in advance
@codewithguillaume
@codewithguillaume 8 ай бұрын
Tokyo night storm 😉
@sofianealloui
@sofianealloui 2 ай бұрын
thank you so much sir you're a legend, ChatGPT wasn't helping with this
@edgardejesusmendozaortegon7655
@edgardejesusmendozaortegon7655 11 ай бұрын
Thanks teacher!!!! Excelent video!!!!
@Eye974
@Eye974 4 ай бұрын
thx
@LeonardoLuzx
@LeonardoLuzx 4 ай бұрын
in this way was not possible to use generateStaticParams, thats a server component function.
@frenchmike
@frenchmike 6 ай бұрын
but isn't it bad to make the root layout a "use client" ? also won't it make everything downstream a client component and page ?
@codewithguillaume
@codewithguillaume 6 ай бұрын
Yep depends on what you want
@VadimBogomazov
@VadimBogomazov 7 ай бұрын
What is I want to set metadata in layout file? If I put "use client" it is not gonna work
@joao-pedro-alves
@joao-pedro-alves 9 ай бұрын
Well, that's a good workaround to work with contexts but an annoying problem about that approach is that all components which are going to use the context need to be client-side. components client side can't be async. So, in my case I'm trying to share to all components the current locale to implement i18n but i need to use an async useTranslation hook and this approach fails in this case, a very common case btw
@codewithguillaume
@codewithguillaume 9 ай бұрын
Absolutely, it really depends on how you want to build your app: client or server. On next examples I’ll explain more 😉
@galaxian9393
@galaxian9393 8 ай бұрын
You should "use client" in the context file, isn't it ?
@rykageee
@rykageee 8 ай бұрын
Hey :) can you do a demonstration on how to do NextJS global context with XState Machine?
@leandrojuarez1794
@leandrojuarez1794 8 ай бұрын
Nice video
@les6837
@les6837 4 ай бұрын
bro how did you put layout as use client??
@awais_ansarii
@awais_ansarii 5 ай бұрын
@codewithguillaume
@codewithguillaume 5 ай бұрын
Thanks my friend
@bujerolandia
@bujerolandia 7 ай бұрын
Great content bro! Your video really helped me to set a global context for my app very easily and fast! Using NextJs 14 and Ts
@adrielamadi8585
@adrielamadi8585 6 ай бұрын
can you please provide the link to the code
@codewithguillaume
@codewithguillaume 6 ай бұрын
Description 😉👍
@JosuaTampubolon-rv3pg
@JosuaTampubolon-rv3pg 9 ай бұрын
makasih bang sangat membantu
Store (Zustand) with Next.js 14 - Course part 19
9:00
Codewithguillaume
Рет қаралды 17 М.
All 17 React Best Practices (IMPORTANT!)
1:46:11
ByteGrad
Рет қаралды 170 М.
Não sabe esconder Comida
00:20
DUDU e CAROL
Рет қаралды 34 МЛН
黑的奸计得逞 #古风
00:24
Black and white double fury
Рет қаралды 25 МЛН
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 83 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 262 #shorts
00:20
Cache explained with Next.js 14 - Course part 16
10:32
Codewithguillaume
Рет қаралды 14 М.
Context API in react | get the concept
29:00
Hitesh Choudhary
Рет қаралды 62 М.
Next js Tutorial for Beginners | Nextjs 13 (App Router) with TypeScript
1:02:55
Programming with Mosh
Рет қаралды 696 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 57 М.
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 110 М.
Next.js 14 Tutorial - 58 - Context Providers
6:08
Codevolution
Рет қаралды 24 М.
5 Tips and Tricks To Make Your Life With Next js 14 Easier
17:11
developedbyed
Рет қаралды 41 М.
Seo & Metadatas with Next.js 14 - Course part 13
13:19
Codewithguillaume
Рет қаралды 8 М.
Não sabe esconder Comida
00:20
DUDU e CAROL
Рет қаралды 34 МЛН