STOP using useState, instead put state in URL (in React & Next.js)

  Рет қаралды 206,063

ByteGrad

ByteGrad

Күн бұрын

Пікірлер: 426
@alexnelson2119
@alexnelson2119 8 ай бұрын
A note about replace vs push, the Link component takes a `replace` prop that you can set to true (default is false) if you want the replace behaviour. It also has a `scroll` prop that you should set to false (default is true) if you don't want to scroll to the top of the page each time you click on an option.
@ByteGrad
@ByteGrad 8 ай бұрын
Yeah, good points
@kamehameha38
@kamehameha38 4 ай бұрын
Arigato
@samyakpiya
@samyakpiya 9 ай бұрын
You are so good at teaching web dev. I love that you show how something can be done with just JS and then proceed to show how a framework like Next.js makes it much simpler! Also, I really appreciate that you cover the edge cases and best practices. I'm learning a lot from watching your videos!
@dimitrisborbotsialos
@dimitrisborbotsialos 10 ай бұрын
We’ve actually used this technique 4 years ago on a react application, worked great and still does. We’ve also made a search component to listen for changes on the url and update a context. Our app was complex and many components had to be updated so using a context was the way to go. It’s funny though that no matter what we do we always coming back to 00’s concepts. It’s like php back in the days.
@Diegps
@Diegps 10 ай бұрын
it's php with a mint flavor and I'm here for it
@spicynoodle7419
@spicynoodle7419 10 ай бұрын
Modern PHP with HTMX is the dream and I'm living it
@billypentester
@billypentester 10 ай бұрын
It depends on the requirements. If you're developing apps that don't share data like admin panels, use states and react. But if you're developing sites that do share data like e-commerce websites, use params and next js.
@developerpranav
@developerpranav 10 ай бұрын
This is awesome with server components! Very detailed video that includes URL encoding and search params. Waiting for your nextjs course :D
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks! 😃
@saadelfadil
@saadelfadil 6 ай бұрын
I stumbled upon your KZfaq channel just today and had to reach out immediately to express my gratitude for the incredible content you’re sharing. Even though it's only been a day, I've already spent hours soaking in your insights. The way you explain concepts is nothing short of amazing 🔥🔥
@webdev_telugu
@webdev_telugu 10 ай бұрын
Such a niche concept and he teaches us for free even though he has paid courses. Kudos my man!!
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks
@RealRatchet
@RealRatchet 10 ай бұрын
It's not a niche concept putting stuff in query parameters was how Web1.0 did things because there was no client state, we've officially come full circle.
@shrin210
@shrin210 10 ай бұрын
​@@RealRatchetNow we write in components and not in pages. That's the only thing changed from Web 1.0
@webdev_telugu
@webdev_telugu 10 ай бұрын
@@RealRatchet yeah true, but I'm a new developer so new thing to me
@henriquematias1986
@henriquematias1986 10 ай бұрын
What you mean niche concept? That’s how the internet works and always worked 😊 It’s just that some websites are broken so he’s teaching how to fix it 😅
@lets_see_777
@lets_see_777 8 ай бұрын
somehow your teaching method resonates best with me. There are several popular youtubers on JS but you explain why we are doing things with alternatives. Thank you.
@coffeefps
@coffeefps 10 ай бұрын
This is actually clean and good. Just need to handle the magic strings gracefully and it's perfect. You earned my sub.
@maisamafshar
@maisamafshar 10 ай бұрын
Excellent presentation and explanation. Loved the pace of the video, not slow, not fast. Subscribed.🤩
@LePhenixGD
@LePhenixGD 10 ай бұрын
Amazing tutorial man! Never had that idea to use URL parameters not for a search but for products until now, thank you!
@guilhermeferreirabr
@guilhermeferreirabr 10 ай бұрын
Dziękuję bardzo za tutoriale, właśnie kupiłem dwa twoje kursy, niesamowita treść! 🚀👏🎬
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks Guilherme! Appreciate it
@ebratz
@ebratz 9 ай бұрын
This tip saved me a lot of time today! Thank you so much! Eager waiting for your Next.js course!
@simoncunningham2964
@simoncunningham2964 2 ай бұрын
Thank you for this video - I've watched a lot of tutorials lately that go down the route of useState and useEffect but they never felt like the best way - glad I came across this video!
@foreverl01
@foreverl01 10 ай бұрын
I found your videos last week and I've seen more than 10 hours of your content. The way you explain things is amazing. Thanks, Wesley! I'm making an e-commerce myself to practice react and next.js, using app router. This solution to avoid using state and making components CC is great! I can't wait for the next js course!! 🥳
@ByteGrad
@ByteGrad 10 ай бұрын
Awesome, thank you!
@saitharunreddya2046
@saitharunreddya2046 10 ай бұрын
An awesome video with great details and explanation, loved it!!! Keep Up the good work
@seg_fault
@seg_fault 9 ай бұрын
Thanks for the video. I heard of this and needed to see an example of how to go about it and this went above and beyond with even the pitfalls to watch out for.
@jou3883
@jou3883 9 ай бұрын
I love you. You’re an awesome teacher. I’m grateful to have found your channel 🙏🏻
@vikasni95
@vikasni95 10 ай бұрын
Im very lucky to find your channel on random search.. Tq god for suggesting this gem channel... Tqss dude keep adding more videos 😍👍
@Olga-id1qy
@Olga-id1qy 8 ай бұрын
Beautiful, it made me smile for a sec as I would write it exactly as you mentioned at the beginning via useEffect(). Now while transitioning to Next.js, I like definitely this one-way approach
@silentlyow
@silentlyow 10 ай бұрын
I recently started a project on a brand new framework recently (Next.js) with TypeScript as well (first typescript experience as well) and discovered this method of handling something like "state" in server components. Basically I had a product page and needed to do pagination and filtering, I did it using the query string.
@kevin-ty7it
@kevin-ty7it 10 ай бұрын
I have a short attention span, but you shared information continuously, which kept me engaged throughout.
@ardianhotii
@ardianhotii 10 ай бұрын
This video was very helpful, I'm learning so many new things from you that I didn't know that can cause problems in my apps. Thank you so much
@pi3ni0
@pi3ni0 9 ай бұрын
Thanks, very good content. A lot of real world cases, can't wait for your course! :)
@James-rd1sb
@James-rd1sb 10 ай бұрын
I never thought of it like this. I'm sure it'll be useful to know in the future! Many thanks
@veedjohnson
@veedjohnson 10 ай бұрын
Definitely one of the best out there!
@mu_yaser
@mu_yaser 10 ай бұрын
wanted to use this concept in my latest next project and you just explained things i needed to know, good info and explanation
@Anonymousssss368
@Anonymousssss368 10 ай бұрын
The content was amazing. I used this approach in my project.
@user-ge2vc3rl1n
@user-ge2vc3rl1n 10 ай бұрын
This is a very cool and unique example, looking forward to more. GJ
@Scrappycoco
@Scrappycoco 10 ай бұрын
Great content man. Keep it up!
@MOURADSLIM
@MOURADSLIM 10 ай бұрын
I'm doing a search function and was gonna use a state manager to manage this problem, perfect timing XD Thank you
@ganumba11
@ganumba11 10 ай бұрын
amazing content from you like always 🔥🔥
@arinium
@arinium 5 ай бұрын
You make absolutely great tutorials, thank you for sharing!
@i.j.5513
@i.j.5513 10 ай бұрын
Very nicely explained and demonstrated 👍
@OpenCoreX
@OpenCoreX 10 ай бұрын
This is just amazing. Glad I discovered you - amazing teacher. #subscribed
@igboanugwocollins4452
@igboanugwocollins4452 10 ай бұрын
Neat approach, you just gained another sub
@codewithguillaume
@codewithguillaume 10 ай бұрын
Huge fan of this approach :)
@NOTHING-en2ue
@NOTHING-en2ue 10 ай бұрын
very well tutorial, you finally teach me how to think the next-js way ❤
@filipniklas
@filipniklas 10 ай бұрын
Great video! Super helpful and well presented!
@weebdeveloper
@weebdeveloper 10 ай бұрын
True, derived state makes some features so much simpler to build, thanks for sharing
@mohammedelmoutaouakkil
@mohammedelmoutaouakkil 9 ай бұрын
Great tutorial! you got a subscriber
@WojciechBlachut
@WojciechBlachut 10 ай бұрын
That is an excellent video! Thanks so much.
@rubelhossain8517
@rubelhossain8517 10 ай бұрын
amazing content ! Keep up the good work sir
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks, will do!
@billypentester
@billypentester 10 ай бұрын
It's really something great for me, actually, I'm looking for something similar to this concept and I got it. So much thanks sir
@mmaarafat
@mmaarafat 8 ай бұрын
thanks, mate. it was great explanation :)
@romeorel1679
@romeorel1679 10 ай бұрын
Never knew you have had a KZfaq channel. I discovered you from your CSS udemy course. Quality work.
@TitoMitto
@TitoMitto 9 ай бұрын
Your tutorials are very informative
@oidualx
@oidualx 9 ай бұрын
Thank you so much! This way of handling state is nothing knew, but I personally never put much thought into it until this video, and always defaulted to client state, with all the issues you listed. Typical aha moment. From now on you convinced me to always default to query params to handle state, unless there is a serious reason not to do so.
@nomadshiba
@nomadshiba 10 ай бұрын
not using react or next, or tsx but this is so true! especially for modals, i like to keep my active modal info on the hash part of the url that way both page data and modal data can be placed on the url but of course you can use url params too i mean you realize that your site/app needs this the moment you refresh the page
@mohammadshariarparvez669
@mohammadshariarparvez669 9 ай бұрын
watching your first video , became a fan of you broooooooo.. god bless you
@loydcose2780
@loydcose2780 10 ай бұрын
Amazing, super helpful!
@user-qo6jf6jk2c
@user-qo6jf6jk2c 10 ай бұрын
many thanks for great content ❤
@glauberbispo8922
@glauberbispo8922 10 ай бұрын
mind blowing I always work with states, i'm looking foward to implement this solution in some of my works *-* and it works really good together with server side in next
@aamiramin6112
@aamiramin6112 10 ай бұрын
So informative. Thanks for sharing
@LearnFrontendNow
@LearnFrontendNow 10 ай бұрын
Always a super useful technique especially for UI's that you likely want to remember state when you copy and paste the link.
@shubhojeetbera
@shubhojeetbera 10 ай бұрын
This was great & easy 👌🏻
@juanhedderich
@juanhedderich 10 ай бұрын
That was awsome, ty man!!
@dero433
@dero433 10 ай бұрын
Dzięki za porady!
@ByteGrad
@ByteGrad 10 ай бұрын
Bez problemu!
@darwin2642
@darwin2642 10 ай бұрын
Thanks for this video, it helped me a lot.
@DiogoLScarmagnani
@DiogoLScarmagnani 8 ай бұрын
Wow! I didn't know about History API and its pushState method. Great! It can be used even in vanilla JavaScript projects. Thank you for the video.
@kumardeepam
@kumardeepam 10 ай бұрын
This is so insightful and useful
@mohammadmo9290
@mohammadmo9290 10 ай бұрын
Amazing, thanks mate 👌👌
@giandenorte
@giandenorte 10 ай бұрын
Just subscribed, I love your content man! I wish the audio can be improve soon.
@ByteGrad
@ByteGrad 10 ай бұрын
Yes, will improve soon. 2-3 more videos with this haha
@ByteGrad
@ByteGrad 10 ай бұрын
My Professional React & Next.js course is OUT NOW now! Find it here: bytegrad.com/courses/professional-react-nextjs -- this is the #1 resource to master the latest React & Next.js, my absolute best work.
@brancode404
@brancode404 10 ай бұрын
Can't wait for it. I hope it'll be out this Month? 😮
@ByteGrad
@ByteGrad 10 ай бұрын
@@brancode404 Sending the exact date to email subscribers :)
@thevasupodcast4561
@thevasupodcast4561 10 ай бұрын
Can you please also club react jobs that you find in your newsletter?
@youneshenni5417
@youneshenni5417 10 ай бұрын
What application will you build in the upcoming next js course? Looking forward to it :)
@ByteGrad
@ByteGrad 10 ай бұрын
@@youneshenni5417 I''ll show screenshots of them soon in the newsletter
@iBryanKops
@iBryanKops 10 ай бұрын
Thanks for this content broth
@Wer-n3r
@Wer-n3r 10 ай бұрын
Dobra Robota
@raymondmichael4987
@raymondmichael4987 10 ай бұрын
I had similar use case today, pulled my hair for hours; Thanks brother 😊
@ammaralshathry9186
@ammaralshathry9186 10 ай бұрын
really. incredible. keep up
@septiantonrezkirahmatulloh3837
@septiantonrezkirahmatulloh3837 10 ай бұрын
thank you, sir. from your knowledge. I am learned something new from this.
@ChrisHaupt
@ChrisHaupt 6 ай бұрын
That's a really cool trick using the Link component to append a query param. Didn't know that was a thing!
@ota-ke
@ota-ke 10 ай бұрын
Pretty well explained. I didn't know server components get the searchParams as props by default!
@saputrauta09
@saputrauta09 9 ай бұрын
Thankyou so much!
@lorsothy6263
@lorsothy6263 10 ай бұрын
Thank you so much. Now I found a way to select filters without use client.
@johncaballero5463
@johncaballero5463 10 ай бұрын
Exactly what I need right now.
@jerryfrancis7495
@jerryfrancis7495 10 ай бұрын
Am seriously anticipating your next js and react course. Great content as always
@ByteGrad
@ByteGrad 10 ай бұрын
Great to hear Jerry!
@user-tq6kn5bv8h
@user-tq6kn5bv8h Ай бұрын
a very intense video ,thank you very much teacher.
@UwU-dx5hu
@UwU-dx5hu Ай бұрын
you are amazing at explaining ❤
@DerberAlter
@DerberAlter 4 ай бұрын
thank you, this video helped me quite a lot
@ogbillity
@ogbillity 10 ай бұрын
I cant thank you enough for this tutorial.
@ThugLifeModafocah
@ThugLifeModafocah 10 ай бұрын
Very good video. Thank you.
@thevasupodcast4561
@thevasupodcast4561 10 ай бұрын
I love your videos. Thank you!
@ByteGrad
@ByteGrad 10 ай бұрын
Glad you like them!
@HerrThomasE
@HerrThomasE 10 ай бұрын
thank you very much for this Great explanations,,!,,!!
@marchugans
@marchugans 10 ай бұрын
Great approach
@ByteGrad
@ByteGrad 10 ай бұрын
I agree, underused by many devs
@youssefaserrar2001
@youssefaserrar2001 10 ай бұрын
You way of explaining is Awesome, I love you videos.
@ByteGrad
@ByteGrad 10 ай бұрын
Thank you so much 😀
@mohamedbelaouer1696
@mohamedbelaouer1696 10 ай бұрын
I juste love your content. thank you for your useful videos
@taicheeeee
@taicheeeee 10 ай бұрын
Best youtubers for beginngers: Lama Dev, and Net Ninja Best youtuber for junior and middle developers: YOU
@ByteGrad
@ByteGrad 10 ай бұрын
Haha thanks
@BK-qx3qf
@BK-qx3qf 10 ай бұрын
You got subscriber. Nice tutorial.
@AndersonSousa33
@AndersonSousa33 10 ай бұрын
Your videos are awesome! Just need to raise the audio volume a little bit.
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd Ай бұрын
Thanks, very helpful informations
@MdNaimurRahmanHera
@MdNaimurRahmanHera 10 ай бұрын
An awesome technique 😍😍
@Alex-bc3xe
@Alex-bc3xe 3 ай бұрын
freaking smart way of making the state in the URL never crossed my mind smart ass shit.
@lukas.webdev
@lukas.webdev 10 ай бұрын
Great video!! Thanks for sharing. 😉🔥
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks for watching!
@eedeenet
@eedeenet 10 ай бұрын
Just a note: I tried, lifting up my state to the url path. But in my specific case, it made the app very unresponsive. I do not know why. It was basically for a filter component. But after changing the filter (tried both params and searchParams) it would sometimes take seconds or even longer until the new state was shown in the app (both in url and component). Do you have any idea why this could be? I had eliminated all client components, it seemed to just be a lag in the client -> server communication? I was fetching data in a `page` which i would then filter by the route params and pass the filtered data down to a list component and the filter component to display the active state. Any tutorial on that (real world use case) with fetching data, I would be happy about.
@iamnguyenhoanganh
@iamnguyenhoanganh 5 ай бұрын
great video, thank you
@bklynpeter
@bklynpeter 9 ай бұрын
Another amazing video. I do have a follow-up question: In your example, the page is a presumably dynamic route? How do we utilize those dynamic elements (again, in your example, 'product' and 't-shirt') at the same time we are accessing the query-params? Thanks as always!
@404-not-found-service
@404-not-found-service 4 ай бұрын
Thanks for the video, I liked it a lot, will you by any chance upload more material like this also using useOptimistic and so on? all the best
@alitonoliveira1700
@alitonoliveira1700 9 ай бұрын
awesome!
@stephenngeorge
@stephenngeorge 10 ай бұрын
This is a really great video :) and super interesting. I know it's nothing to do with the video but the "JavaScript magic" to make the first letter uppercase on those buttons is just "text-transform: capitalize;" in CSS 👍
@redeemr
@redeemr 8 ай бұрын
or since he's using tailwind just className="capitalize"
@chrishanthacosta4093
@chrishanthacosta4093 7 ай бұрын
I find Wesley to be the best NextJS teacher.
@ZacharyBetz
@ZacharyBetz 10 ай бұрын
In case you weren’t aware, your content is top notch 👌
@ByteGrad
@ByteGrad 10 ай бұрын
Thanks Zachary, always good to hear :D
@gmjitendra
@gmjitendra 4 ай бұрын
Excellent. thanks
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 130 М.
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 9 МЛН
My Favorite State Manager Is...URLs?
6:29
Theo - t3․gg
Рет қаралды 70 М.
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 497 М.
Why I don't use React-Query and tRPC in Next.js
18:58
ByteGrad
Рет қаралды 80 М.
10 common mistakes with the Next.js App Router
20:37
Vercel
Рет қаралды 197 М.
All 29 Next.js Mistakes Beginners Make
1:45:10
ByteGrad
Рет қаралды 97 М.
Next js Tutorial for Beginners | Nextjs 13 (App Router) with TypeScript
1:02:55
Programming with Mosh
Рет қаралды 597 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 170 М.
The Easy Way to Design Top Tier Websites
11:54
Sajid
Рет қаралды 198 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23