Пікірлер
@niteshrathore4341
@niteshrathore4341 7 сағат бұрын
There is one catch here if i want to open that model in app component then i need to state then only i can open the model and state change will cause the re-render of other component
@TadStrange-cu5qh
@TadStrange-cu5qh Күн бұрын
At 6:37, did you mean the comparison between "Before" <Child/> and "After" <Child/> when the state change, isn't it?
@user-rk7dm1xm3r
@user-rk7dm1xm3r Күн бұрын
The best blogger ever! I want your next.js course to watch next
@boyywnkobe
@boyywnkobe 2 күн бұрын
3:31 у вас помилка, має бути false a є true в субтитрах
@developerwaypatterns
@developerwaypatterns 2 күн бұрын
There is neither true no false at that time? 🤔
@boyywnkobe
@boyywnkobe 2 күн бұрын
@@developerwaypatterns sorry, 3:28
@mariolazzari
@mariolazzari 2 күн бұрын
Brillant! This is NOT the usual React course you can find in many other places (with all due respect speaking): this is a pure gem!
@user-rk7dm1xm3r
@user-rk7dm1xm3r 3 күн бұрын
06:45 2 episod - mistake. should be return false - not true or I just do not understand this 2d episod at all. Explain please who can
@developerwaypatterns
@developerwaypatterns 3 күн бұрын
No mistake. If the comparison of types returns "false", then it would mean that the element "before" is radically different to the element "after". The element "before" then would be removed from the structure and the element "after" added from scratch. I.e. "div" to "p" transition: div is removed, p is added. Div is unmounted, p is mounted. If the comparison returns "true", that mean that the element "before" and "after" is the same, just needs an update. I.e "div" to "div" transition - both before and after are divs, div just re-renders. Exactly the same if in "type" you have is a function. If it's the same function - proceed further, i.e. check props and/or "key", and re-render as a result.
@user-rk7dm1xm3r
@user-rk7dm1xm3r 2 күн бұрын
@@developerwaypatterns OK. Make sense. No unmounts. Child components are the same. Parent state changed - react should rerender parent and all children components. It is simple for now. But there is exception for children components that came from prop 'children'. What is it the magic? I do not understand why if I create children components inside of parent or outside (doesn't matter) they will be rerendered but if they came to parent as a 'childen' prop they will not rerender ?
@user-rk7dm1xm3r
@user-rk7dm1xm3r 2 күн бұрын
const Child = () => { return ( <strong>Child</strong> ); }; function Parent() { const [count, setCount] = useState(0); return ( <> <h1>{count}</h1> <button onClick={() => setCount(count + 1)}> Увеличить </button> <Child/> </> ); } In that example Child rerenders on click regardless the fact that it was created outside the parent component. It is understandable.
@user-rk7dm1xm3r
@user-rk7dm1xm3r 2 күн бұрын
const Child = () => { return ( <strong>Child</strong> ); }; const AncectorComponent= () => { return(<Parent><Child/></Parent> )} - in one file In another file: function Parent({children}) { const [count, setCount] = useState(0); return ( <> <h1>{count}</h1> <button onClick={() => setCount(count + 1)}> Увеличить </button> {children} </> ); } - why Child component is no rerendered on click?
@developerwaypatterns
@developerwaypatterns 2 күн бұрын
Because the very first thing React checks is whether the Element changes. It starts with the shallow comparison, our normal "===". If the element "before" === element "after", it's a signal to React that the Element stays the same, and there is no need to re-render anything. Element, in your case, is the result of <Child /> - the object with the "type": Child We'll typically have the same reference to this object "before" and "after" in two cases: * when it's memoized with useMemo const child = useMemo(() => <Child />, []) * when it's passed as props that's this case, "children" is just a regular prop
@juliosantiesteban7709
@juliosantiesteban7709 5 күн бұрын
im really curious about the software you use to create the code animations, would you be so kind to share it?
@developerwaypatterns
@developerwaypatterns 4 күн бұрын
Code animations in Keynote, the rest of them usually in Final Cut Pro or again Keynote
@drrodopszin
@drrodopszin 5 күн бұрын
I have subconsciously moved the state down many times when I was implementing Add/Delete buttons; it just felt natural to move out all that fetch logic into its own tidy component, but now I will be doing it consciously.
@user-cn1km3ds5t
@user-cn1km3ds5t 7 күн бұрын
perfect!!!
@drrodopszin
@drrodopszin 7 күн бұрын
I usually see HoCs in plain Javascript and it makes me worried if it is hard to type correctly and elegantly in TypeScript.
@developerwaypatterns
@developerwaypatterns 7 күн бұрын
It is indeed quite challenging
@paulstelian97
@paulstelian97 7 күн бұрын
4:20: Well the problem _just_ mentioned clicked for me and holy cow it’s an annoying and unintuitive issue! Before watching further, my guess is: * Since count is captured at the time of the closure, it’s frozen in time to whatever it is when the callback is registered * Memoization prevents the component from being re-rendered and the closure being replaced with an up-to-date closure with the most recent state * The worst part is I don’t see an obvious solution (does the rest of the video offer one? I expect so, but I’ll watch patiently) as calling useState in an event handler is not gonna work. useRef()? Shouldn’t be needed…. I’ll keep watching. Edit: oh fuck I saw the name of the last chapter. It is, in fact, refs that are used for it. 💀 Edit 2: Well that’s a more clever way to use the closures than I thought.
@mostinho7
@mostinho7 8 күн бұрын
Awesome thanks! Render props pattern is passing a function that when called returns the child component, instead of directly passing the component. Passing child component is not flexible, example is Button and icon component you pass icon as a prop to button. Button can control what props of are passed to icon but if icons prop AP changes then this will break without noticing. How to share state with children render props Why you should use hooks instead When to still use render props
@mostinho7
@mostinho7 8 күн бұрын
Thanks for the insightful video Summary: you don’t want to directly pass elements as props, instead you should use render props pattern (next video) but even that custom hooks are usually more suitable in 99% of situations
@drrodopszin
@drrodopszin 9 күн бұрын
Around 12mins there was this pattern: `{isSomething ? <Something /> : null}`. Will it be the same result if I use `{isSomething && <Something />}`? Or in that case instead of having an `undefined` element in the array the element is omitted (therefore the bug stays)? I am asking because if these 2 are not equivalent, then this solution has a very high risk of suffering "death by refactor": someone sees it, assumes it was written by somebody who forgot about `&&` and rewrites it like that. Update: it works as expected, a potential refactor won't kill it.
@developerwaypatterns
@developerwaypatterns 9 күн бұрын
Yep, it's the same, I just slightly prefer the explicit version rather than &&, for me it's easier to read :)
@JamesBoyle-xj3yj
@JamesBoyle-xj3yj 10 күн бұрын
I read your book twice, now im happy to find your making videos too... The best react content out there BY FAR.. thank you
@haallefs
@haallefs 10 күн бұрын
hey, I couldn't reproduce the example "Intercepting DOM events". I've tried several approaches, but it didn't work.
@developerwaypatterns
@developerwaypatterns 10 күн бұрын
Make sure that you set focus inside the modal
@rishabhmishra9611
@rishabhmishra9611 10 күн бұрын
is it just me who is enjoying this series more than any Hollywood series?? great explanations and narration also 👌
@developerwaypatterns
@developerwaypatterns 10 күн бұрын
😊
@ravneetsinghanand1589
@ravneetsinghanand1589 10 күн бұрын
Amazing course! Thank you 🙏
@florenciobritez5521
@florenciobritez5521 10 күн бұрын
When the App component rerenders at 3:23 it will run each child component again but will only update the DOM when the execution of all the children has finished, right? @developerwaypatterns 🤔
@developerwaypatterns
@developerwaypatterns 10 күн бұрын
Yep, unless you're doing something async there in useeffect IIRC
@florenciobritez5521
@florenciobritez5521 9 күн бұрын
@@developerwaypatterns Thank you for responding and for sharing your knowledge with us!
@omak3313
@omak3313 10 күн бұрын
Спасибо! Очень полезно! Будет обновление курса и книги после релиза React 19? Собираюсь купить вашу книгу)
@developerwaypatterns
@developerwaypatterns 10 күн бұрын
I can't make any promises, sorry :)
@mostinho7
@mostinho7 11 күн бұрын
Thanks for the great video! 1:40 problem is that state frequent state change is at the parent component level which has a bunch of slow children that will rerender everytime state changes. You should move state down to fix this problem if you can (moving state to the child component that needs it instead of having state at the parent level). In this case, that’s not possible because what triggers state change is the wrapper div that encapsulates the children 2:10 composition trick, making the outer div component that triggers the state change take the heavy/slow children as props and then render them, instead of them being defined in the same component (getting them as props vs defining them in the same component) solves the issue of slow/heavy components re-rendering This doesn’t make sense at first because technically they’re still children of the outer div component in the react tree, but they don’t re-render when the outer div component state changes 5:30 diffing an reconciliation, understanding how react compares elements and decides to rerender explains why the composition trick prevents the heavy child components passed as props from rerendering when state changes 6:20 summary
@dianaduran159
@dianaduran159 12 күн бұрын
You explain so well, love it 😅
@21agdmnm
@21agdmnm 12 күн бұрын
Bought your book after watching some of your videos, you explain so well!
@drrodopszin
@drrodopszin 12 күн бұрын
Now watching the entire thing, it is logical but very very sad, that passing a blob of HTML without any variables in it will trigger rerender because it is just an object created after all. I _love_ the children pattern as it makes code very readable, but all that is lost if I have to memoize it through (quite counterintuitively) `useMemo`.
@developerwaypatterns
@developerwaypatterns 10 күн бұрын
Yeah, it's pretty much why i almost never use memoization - it's so counterintuitive and close to impossible to get it right and to keep it not broken, if working in a team with multiple developers
@drrodopszin
@drrodopszin 12 күн бұрын
Top quality, super clear explanation! I have just subscribed as a senior dev. On a total side note, I almost never needed useCallback probably because we used overmindjs (a UX friendly version of redux) and the combination of subconscious patterns: for example a submit function is called as a reaction to a submit event and not in useEffect hook. Therefore on renders submit is not called, only on user interactions. Anyways I made myself a debug hook, that you can pass an array and it outputs which variable changed since the previous render. It's super useful to test dependencies.
@haallefs
@haallefs 13 күн бұрын
This video has helped me a lot to learn more about React.memo. Thanks
@omprakashdeshmukh9850
@omprakashdeshmukh9850 13 күн бұрын
Hi Developer, you are creating the best videos, please create videos for JavaScript as well.
@mostinho7
@mostinho7 16 күн бұрын
Done thanks! When a react component n rerender due to a state update, all the child components defined in it will rerender by default. So you should move state down when possible to be specific to the component that needs to rerendered to avoid rerendering other components that don’t rely on this state variable
@rosscarnegie393
@rosscarnegie393 16 күн бұрын
Thank you for all this excellent content. I think your videos are useful for any level. Your videos are way more substantive than most, the way you deep dive into things and don’t just stay on the surface and just really get under the hood is extremely useful, and you explain things with an unmatched clarity and detail. I find myself going back to these videos mentally and literally all the time whenever I hit a wall. Im a professional developer and watch your videos even if they’re discussing what I already know- and still I walk away with a better understanding. Your content is top shelf. Please keep up the excellent work.
@developerwaypatterns
@developerwaypatterns 16 күн бұрын
Thank you, that's so great to hear! 😊
@mj2068
@mj2068 16 күн бұрын
thank you very very much for this.
@jonathanchen4978
@jonathanchen4978 17 күн бұрын
These videos are amazing!!! Thank so much!
@shaungedye7727
@shaungedye7727 22 күн бұрын
This is a fantastic resource and clear explanations, thanks :) FYI - There is a bug @12:21 - should remove the "!" before "isCompany", or else swap the return values. At the moment if isCompany is true it will return [{ type: Checkbox }, { type: Input }, { type: Input }] and if it is false it will return [{ type: Checkbox }, null, null]
@developerwaypatterns
@developerwaypatterns 20 күн бұрын
Ooops! Indeed 🤦🏼‍♀🤦🏼‍♀ Great catch!
@skchintu6172
@skchintu6172 22 күн бұрын
wonder full tutorial mam, i loved your explanation 💌
@roshnikashyap9588
@roshnikashyap9588 23 күн бұрын
Mindblowing! Now I am going to get rejected in interviews because most architects wont know this much :D
@developerwaypatterns
@developerwaypatterns 22 күн бұрын
Haha, I hope not 😅
@alexandreagra239
@alexandreagra239 25 күн бұрын
This is very amazing. Thank you so much, big W !!!
@aeldarets
@aeldarets 29 күн бұрын
How is this going to work with TypeScript?
@developerwaypatterns
@developerwaypatterns 28 күн бұрын
same as with javascript
@nehat786
@nehat786 29 күн бұрын
Awesome!
@CHN-yh3uv
@CHN-yh3uv Ай бұрын
I though I was a senior dev but this popped my bubble real fast 🤣 but in all seriousness, who the hell is designing this thing? This is not a library it’s a minefield. God I miss VueJS
@developerwaypatterns
@developerwaypatterns 29 күн бұрын
😅
@RegalWK
@RegalWK Ай бұрын
Love your blog!
@InterestingTed
@InterestingTed Ай бұрын
Beautiful video, the first one too. Subscribed!
@murali-krishnan
@murali-krishnan Ай бұрын
Crisp and straight to the point content, Thx Nadia
@aeldarets
@aeldarets Ай бұрын
This is gold
@Hattorihanzo330
@Hattorihanzo330 Ай бұрын
Thank you for all your videos and for your amazing book!
@newaroundhere
@newaroundhere Ай бұрын
Your videos are gold, mate 👏Very few creators go so deep into how React really works.
@anirudhnomula2942
@anirudhnomula2942 Ай бұрын
U need a million subs for the amazing content reality love the quality tq for all ur efforts
@Matter743
@Matter743 Ай бұрын
I have doubt.. can we dynamically insert element to the list until it doesn't fit. like here we first first render it initially and call useLayoutEffect hook which will calculate the width of the elements before the painting ..but can we do it dynamically calculating on the go and inserting element to list if not why not?
@paulstelian97
@paulstelian97 6 күн бұрын
My guess is I don't think you can layout multiple times without creating a poor experience, especially not within the same "frame".
@ka5539
@ka5539 Ай бұрын
This was very useful. Thank you!