Hope you enjoyed the video! I also have a really cool and unique course that will teach you way more than this video. You'll learn how to build an actual complex project with React. It's called "Project React" and you can find it at cosden.solutions/project-react. Also, I have a free weekly newsletter called "Import React" with tutorials, news, and cool stuff about React! You can sign up at cosden.solutions/newsletter?s=ytc
@kennardsugirotok737411 ай бұрын
Please do more of these refactoring. Really helps especially for beginners like me
@fellypsantos_11 ай бұрын
I've learned more in 15 min them that in 1 year
@VineetS-s5x8 ай бұрын
Your videos are truly remarkable! I've been on the hunt for quality content like yours for months and finally stumbled upon the right place. My gratitude for your excellent videos
@jaortiiss11 ай бұрын
This could be a real scenario of a PR session. A senior dev explaining concepts to a junior one in a real life project. Pure GOLD.
@ry90210 ай бұрын
Need more of this . Really helps when you knows the react framwork but don't know how to apply them in actual practical scenarios .
10 ай бұрын
I really like your approach "hooking" the logic when needed. One little thing I would add is using constants in a separated file of same name, for example: const CACHE_INTERVAL = 100 * 60 * 60 const PAGE_VIEW_ANALYTICS_ID = "page_view" And reuse them and even if someday you need to rename / change values, you do it in only one place: 🙂 ... GcTime: CACHE_INTERVAL, staleTime: STALE_INTERVAL ... trackEvent(PAGE_VIEW_ANALYTICS_ID, ...
@abrahamibizugbe4774 ай бұрын
Mehnn.. this is the smartest idea for a SE tutorial content I have seen on YT.. You're doing a great job Man❤️❤️
@excelnutcracker431210 ай бұрын
I'm new to react and TIL, a whole component re-render when a piece of state change. I never knew why would you want to put the modal open state inside and think like 'I can prevent all of this component to render'. Great and clear explanation!
@joaomarcelofurtadoromero827711 ай бұрын
Gold content, would love to see more refactoring
@irfansaeedkhan724211 ай бұрын
where were you all this time, i was searching for this practical videos for a long time, thank you so much
@cosdensolutions11 ай бұрын
well, I'm here now ☺️
@chrismixlist11 ай бұрын
your videos provide information with great value 👌
@NaDennIsGut11 ай бұрын
i love your style. just straight to the point and fast delivery of information. please do more refactorings :) subscribed
@cosdensolutions11 ай бұрын
will do!
@nickwoodward81911 ай бұрын
Only a third through it, but this video is fire. Please do more of these!
@BSK_Rick10 ай бұрын
awesome video man! I will share it with my co-workers
@cristhianjhlcom11 ай бұрын
Hello, do you have any video explaining how to organize project folder for big projects? 💪🏽
@prashlovessamosa11 ай бұрын
He already created a video.
@fdk.539011 ай бұрын
@@prashlovessamosa That's what he asked.
@nickwoodward81911 ай бұрын
Take a look at examples from state management packages like rtk query, they tend to give decent structures
@coder_one11 ай бұрын
I am a bit concerned about writing custom hook with useEffect (last part of video). The IDE can catch quite well if we omit some variables from the useEffect dependency array. By pulling this out into a self-written hook, we completely get rid of support for catching potential errors/missing variables in the dependency array. This can lead to " Reacts one million dollar mistake "...
@andrewbarnes10210 ай бұрын
That’s a great point actually. Wonder if there’s any way around it.
@a7mdbest1511 ай бұрын
Loved the video, refactoring is actually what we need to learn
@iLLiaGoncharov-d1r10 ай бұрын
Using null instead of undefined for explicitly set properties can be a good practice to make the code more explicit and reduce ambiguity.
@nabeelmalik6227Ай бұрын
great content man. loved it.
@sondernfy11 ай бұрын
Love this! Would be nice if you also included the equivalent (or closest approximation) to these in JavaScript as well so we could have a direct comparison. Awesome video
@bleakCode11 ай бұрын
I really find your videos enjoyable to watch and knowledageable. Keep going!
@belkocik11 ай бұрын
I love these kinds of videos that you explain Design Patterns in React :) Woud love some stuff from React Native too if you can.
@MohamedRabi4 ай бұрын
awesome video! Thank you 👍
@gmjitendra11 ай бұрын
great video, thanks. would appreciate if you also include testing along.
@rjwhite442410 ай бұрын
What is the vs code extension you use for that ts snippet
@HerlonCosta11 ай бұрын
Amazing explanation, thank you so much!
@jech3311 ай бұрын
Hey man I really like your content! I don't know if other people are having the same problem but I think you should turn up the volume on your voice. Somehow when I came from other videos I find myself having to turn up the volume through either my pc or the youtube vid. Keep up the great content! your quality is awesome
@cosdensolutions11 ай бұрын
interesting, you're the first to have mentioned this. I'm soon getting a whole new setup so this should become much better
@jech3311 ай бұрын
@@cosdensolutions awesome
@daveboo700211 ай бұрын
It sounds like your mic is on your keyboard?
@saqibmuhammad721811 ай бұрын
Hats off Bro Really learning lot of new Stuff🥰🥰😍😍
@cruzlee409211 ай бұрын
Great! Thank you for sharing. It's useful for me.
@quanganhinh625211 ай бұрын
Really good video, please do more
@tomassinkevicius678611 ай бұрын
Ideally you only want to send track event when you have a user, but this hook you created will send them even if you don't have one yet.
@cosdensolutions11 ай бұрын
Yeah but you'd just need to add an if check. In this example thr user was there already
@stn1k310 ай бұрын
Good video, however, `useTrackPageView` should not be typed for specific pages, as it goes against separation in concerns, instead is to be agnostic of the page, so the proper solution would require using generics type PageEvent = { pageId: P; data: D; }; type UserProductsPageEvent = PageEvent; const useTrackPageView = (event: T, deps: DependencyList): void => { useEffect(() => { trackEvent('page_view', event); }, deps); }; // consumption useTrackPageView({ data: { userId }, pageId: 'user_products_page' }, [userId]); lastly correct type for dependency array is DependencyList // defined in react as ReadonlyArray.
@codexpath29609 ай бұрын
awesome review
@mustang995111 ай бұрын
quality content
@LinhNguyen-gx5fb9 ай бұрын
nội dung này tuyệt quá hay anh ơi !
@thanirmalai11 ай бұрын
Amazing videos
@ilmanmanarulqori563211 ай бұрын
lets goooo!! 🎉
@exequiel_hyan11 ай бұрын
its a great video, the only thing that i dont think i understood is the deps prop for useEffect... I have a feeling that's going to cause problems in the future, but otherwise, which other options do we have?
@cosdensolutions11 ай бұрын
That's fair, you could just create a wrapper around the analytics function that's properly typed and use that instead without a custom hook. Might be a better option actually
@conallen31669 ай бұрын
Hey Cosden, great tutorials, can you tell me how I can create components using rjsfcp? is there a extension needed to support that? ive tried with copilot without luck. Thanks and keep up the good work : -)
@aminda686211 ай бұрын
great thanks a lot
@mfion110 ай бұрын
Nice video
@mahdiimad144711 ай бұрын
If you have an useEffect that has a dependency on a prop then you don't need an use|Effect you can only add a key prop to the component, and then it will re-render without using useEffect
@jgagnon8811 ай бұрын
This is a bad advice. If the key changes, the component will unmount and then remount
@Shadel.9 ай бұрын
Thanks for video but this video is pretty hard for beginners because this topic 2nd concept on react road map. So, Beginners don't know about hooks. I think you can make that basic like this div, h1,img elements. This topic 2nd concept on road map so "Components" but you mentioned that advanced level react informations. I think you should update to video for "How to split larger components into smaller ones (example 1, example 2)" so you can create that new video for beginners because component Layouts are very important in react development.
@marcelp482510 ай бұрын
Hello ! Why did you choose interface instead type? Great video!
@cosdensolutions10 ай бұрын
No reason, I just use both interchangeably
@teenspirit871410 ай бұрын
how about "array.length &&" checking? sometimes it's works wierd
@uome2k711 ай бұрын
Isnt the track page hook approach the facade design pattern?
@benyamin463411 ай бұрын
thanks
@Kaltste1n11 ай бұрын
What extensions do you use? Especially those onclick import Thanks!
@ZakTheCreator11 ай бұрын
how do i get that 'rjsfc' command that you did?
@tony-gx7rt10 ай бұрын
can you do some videos on vue js 3 , the resources are scarce and especailly on compositon api.
@genericbinary5588 ай бұрын
Ohhh nice. So what if I make a typo in the custom hook file where I defined the interface. 😂😂
@LogopedLTD10 ай бұрын
But eslint react-hook plugin says about warn when put some array of deps from somewhere
@juozasmas11 ай бұрын
Is there any way to automate auto file creation from seelction of jsx? Also for hooks also
@Quintusflac3 ай бұрын
I like it
@-mahmoudadel26285 ай бұрын
Waht about making a video for event tracker and how to integrate google analytics with react? ❤
@MrKarl99211 ай бұрын
Thank you. This content is amazing. Do you have some video explaining the file architecture you use? I mean, which folders would you create for this example if it was a real and scalable project?
@cosdensolutions11 ай бұрын
I have a video on folder structures that goes over this!
@Gringo051711 ай бұрын
Thanks for the content! I noticed you wrapped the new component in a div when I was expecting an empty tag or fragment. As these aren't exactly equivalent in regards to styles coming from a parent (flex-direction for example), I was curious if this was intentional?
@cosdensolutions11 ай бұрын
yeah, I added a div there but you could've not added it. I was focused more on the concept and may have added it by habit :D but definitely only add it if you need it!
@Gringo051711 ай бұрын
@@cosdensolutions thanks for the clarification! Again, thanks for all the great content. In particular the short-form stuff has been great at funneling me back to your longer form information. Liked and subsribed
@aytacklnc664210 ай бұрын
3:55 How could you do rjsfcp command? It is not supported by default. There is no information on the internet.
@cosdensolutions10 ай бұрын
check out my vscode setup video, it's a custom snippet
@albiceleste10110 ай бұрын
I loved the video! At 7:15 you keep calling the function a "custom hook", wouldn't it require react to be imported to be custom hook?
@rea_kr5 ай бұрын
Could you upload the starter code to your GitHub repository? I'd like to follow along while watching the video.
@malekimam144411 ай бұрын
Thank you for the video, I have a question regarding organizing this code block: { products && products.length ? ( ) : ( 'No products available. ' ) } Can we move this logic of checking if there are products inside the component?
@cosdensolutions11 ай бұрын
yeah you totally can!
@onintuverachannel11 ай бұрын
Please do more . how about color system of the codebase? like you dont need a help of css framework that can produce multiple themes in it.
@wakandagaming576311 ай бұрын
hi can u make playlist about react desain pattren? thanks
@Gangbuster7411 ай бұрын
Can you please make a video how to append search params or query params into api end point if they are coming from a select input or anything that manages them, currently I just use ternary operator to append them based on their value if it’s present, I dont think this is the best approach, If you could really help showing a practical approach How big projects and companies or experienced developers does that, that would a really great for community thank you
@aliqureshi419411 ай бұрын
We need a refactoring course 😅
@MohammedShibincp11 ай бұрын
can you make video in react roadmap pls
@cosdensolutions11 ай бұрын
yes, it's coming as soon as the new year starts!
@AndreyBelfu11 ай бұрын
what vs command do you use for importing files?
@cosdensolutions11 ай бұрын
Just normal imports from vscode
@lyrical685211 ай бұрын
Yeah, how to do that import? Whats the shortcut in keyboard?
@codewithhakem10 ай бұрын
@@lyrical6852 Ctrl + space on PC
@shmida199111 ай бұрын
Typescript - work hard to aviod "null of undefined" So much overhead
@ignacioarriagadairiarte433811 ай бұрын
what is your react code snippets extention?
@cosdensolutions11 ай бұрын
check out the video I made on vscode
@abhinavdhama301411 ай бұрын
Bro can we have one redux think middleware video also?
@joseortiz380611 ай бұрын
Pls, what is the theme name of the editor?
@cosdensolutions11 ай бұрын
Vscode
@HelenaDuGraus11 ай бұрын
interface or type for components props?
@cosdensolutions11 ай бұрын
I've switched over to types for everything now
@akhs00111 ай бұрын
You need to show how the app works also, before and after refactoring . Not just the code
@kost3211 ай бұрын
Thanks for video! What about to make UserProductsFilter component as children of UserProductsFilterButton? No props will be drilled, and reused UserProductsFilterButton component as Modal
@cosdensolutions11 ай бұрын
Yeah that's actually better! Nice
@einfacherkerl327911 ай бұрын
the modal and button should not be treated as one component because it violates the single responsibly principal. it has a button that invokes modal and also the modal. the button should start there. only the modal box should b go in separate component. it should take a prop visible that should come from the parent.
@cosdensolutions11 ай бұрын
Sure, you could also do that. It's debatable though because the whole component would re-render if you did it that way but again, it's not that strict it's just one way of doing things out of many
@einfacherkerl327911 ай бұрын
@@cosdensolutions React.Memo would be one solution to rerendering. don't re render until props change
@Pilosofia11 ай бұрын
It is called the single responsibility principle not the single element or component principle.
@einfacherkerl327911 ай бұрын
@@Pilosofia I don't understand what you mean?
@stanislauyan320410 ай бұрын
Single responsibility principle was created for the OOP as part of SOLID principles. In react world the re-rendering should be taken into account. And author is totally correct to make such refactoring. CUPID would fit much better in react, but still you must take into account how react works to make efficient and maintainable code. I think author should not use such name for that part, bcs it confuses a lot.
@DamilolaBada-x3x11 ай бұрын
Your videos have always helped me and even though I'm in your Discord channel, I'd still like to ask if you can mentor a junior developer like me. I'd be waiting anxiously for your reply. Thanks
@cosdensolutions11 ай бұрын
I currently don't do any personal mentoring, but I have these videos and the Discord that really helps! I'm also working on a course that will be extremely helpful as well
@DamilolaBada-x3x11 ай бұрын
@@cosdensolutions Thanks for your quick reply. I am a junior fullstack developer and I'm currently tasked at my current job to do a complete rewrite of the app. I'm completely overwhelmed and need guidance on how to build an enterprise and scalable react app. Could you offer me some help or recommendations? Thanks
@Becherman9 ай бұрын
I am not sure that putting the whole modal into button components is a good idea
@khanhduynguyen472611 ай бұрын
we need src code :(
@xatrox280311 ай бұрын
What is the extension that you use for the snippet "rjsfcp"?
@cosdensolutions11 ай бұрын
I made it myself, see my vscode setup vid
@Wakkyguy11 ай бұрын
Deps [userId] passed to useTrackPageView being a reference type will be changed on every re-render thereby triggering the underlying useEffect of the custom hook again and again. Shouldn't we try to stabilise this reference?
@jamaliseven11 ай бұрын
don't worry, he's a senior and definitely understands react. better to flood your analytics API via beautiful custom hook rather than just wrapping and typing your analytics method (and always enjoyable debugging experience to jump into 100 custom hooks to track down bricked useEffects inside)
@cosdensolutions11 ай бұрын
Yeah, it would be better to do that actually! I didn't think about it while making the video. You could also create your own function that wraps the analytics one and not bother with extracting the useEffect. It's completely up to you!
@Wakkyguy11 ай бұрын
@@cosdensolutions sure, thanks
@aleks633111 ай бұрын
No, as useEffect will check items INSIDE of the deps array for consistency, not the array itself. So this code is perfectly fine and won't retrigger unless `userId` changes.
@Wakkyguy11 ай бұрын
@@aleks6331 Oh, is it? Will check it out sometime.
@davyengone11 ай бұрын
At the moment of writing this comment, this video has 1400 views and 11k likes. Something is off with KZbin. Nice video though
@cosdensolutions11 ай бұрын
Yeah it's a bug, it shows 160 likes and 2.4k on yt studio
@borcio699011 ай бұрын
first x )
@davidezerrilli71110 ай бұрын
I'm always a little bit scared of refactoring without setting unit test before refactoring but you know sometimes business times are not dev times
@gixxerblade11 ай бұрын
UserProductsPage will still be rerendered every time the modal shows.
@cosdensolutions11 ай бұрын
it won't. Child re-renders don't cause parents to re-render