Developer Way
Developer Way
  • 16
  • 161 396
Making sense of Higher Order Components - Advanced React course, Episode 7
👉 Based on the "Advanced React" book, Chapter 7: www.advanced-react.com
🎬 Episode 7: Higher Order Components in the modern world
00:30 What's in the episode
01:01 What is a Higher Order Component
01:42 Injecting props with HOCs
02:26 Enhancing callbacks with HOCs
05:44 Enhancing lifecycle methods
06:06 Intercepting DOM events
👩🏻‍💻 Code examples:
1. Injecting props (theming): www.advanced-react.com/examples/07/01
2. Button with logging on click: www.advanced-react.com/examples/07/02
3. Passing data to HOC: www.advanced-react.com/examples/07/03
4. Logging on mount: www.advanced-react.com/examples/07/04
💬 Twitter: adevnadia
💬 Linkedin: www.linkedin.com/in/adevnadia/
zhlédnutí: 5 157

Video

Mastering React Reconciliation - Advanced React course, Episode 6
zhlédnutí 8KPřed 5 měsíci
👉 Based on the "Advanced React" book, Chapter 6: www.advanced-react.com 🎬 Episode 6: Deep dive into diffing and reconciliation in React 00:34 What's in the course 01:31 The problem we're going to solve 03:24 React reconciliation & diffing - mounting 05:45 React reconciliation & state update 08:37 Why we can't create components inside other components 09:48 The answer to the mystery 11:18 Reconc...
Mastering memoization in React - Advanced React course, Episode 5
zhlédnutí 11KPřed 6 měsíci
👉 Based on the "Advanced React" book, Chapter 5: www.advanced-react.com The fifth episode of the "Advanced React" course. The course will be uploaded episode by episode once every 1-2 weeks. 🎬 Episode 5: Memoization with useMemo, useCallback and React.memo 01:22 Intro to memoization and its purpose in React 03:33 How useMemo and useCallback hooks work - React API 04:55 How useMemo and useCallba...
Render props - Advanced React course, Episode 4
zhlédnutí 8KPřed 7 měsíci
👉 Based on the "Advanced React" book, Chapter 4: www.advanced-react.com The fourth episode of the "Advanced React" course. The course will be uploaded episode by episode once every 1-2 weeks. 🎬 Episode 4: Advanced configuration with render props 00:51 Intro to render props 3:26 Sharing state through children as render props 4:40 How hooks come into play 5:54 When render props can still be usefu...
Components as props - Advanced React course, Episode 3
zhlédnutí 9KPřed 7 měsíci
👉 Based on the "Advanced React" book, chapter 3: www.advanced-react.com The third episode of the "Advanced React" course. The course will be uploaded episode by episode once every 1-2 weeks. 🎬 Episode 3: Elements as props 00:00 The problem 00:47 Generic components with elements as props 2:54 Elements as props - downside 3:42 Default props to elements as props 4:25 Downside of default props 4:57...
Elements, Children and Re-renders - Advanced React course, Episode 2
zhlédnutí 14KPřed 8 měsíci
👉 Based on the "Advanced React" book, Chapter 2: www.advanced-react.com The second episode of the "Advanced React" course. The course will be uploaded episode by episode once every 1-2 weeks. 🎬 Episode 2: Elements, Children and Re-renders 00:00 The problem 00:59 Composition trick to reduce re-renders 3:11 What are the Elements 4:42 How rendering and re-rendering are triggered 5:29 Diffing and r...
Intro to re-renders - Advanced React Course, Episode1
zhlédnutí 29KPřed 8 měsíci
👉 Based on the "Advanced React" book, Chapter 1: www.advanced-react.com The first episode of the "Advanced React" course. The course will be uploaded episode by episode once every 1-2 weeks. 🎬 Episode 1: Intro to re-renders 00:00 The problem 1:41 React lifecycle basics 3:37 Danger of custom hooks 4:53 The big re-renders myth 5:52 Moving state down 👩🏻‍💻 Code examples: 1. The problem: codesandbox...
Fantastic closures and how to find them in React
zhlédnutí 10KPřed 11 měsíci
👉 Advanced React Book: www.advanced-react.com 👉 Fantastic closures and how to find them in React: www.developerway.com/posts/fantastic-closures 💬 Twitter: adevnadia 💬 Linkedin: www.linkedin.com/in/adevnadia/ 👩🏼‍💻 Initial "mystery" code example: codesandbox.io/s/example1-925swq?from-embed=&file=/App.tsx 👩🏼‍💻 Cached closure without React code example: codesandbox.io/s/example2-xx4xq3 ...
React reconciliation: how it works and why should we care
zhlédnutí 11KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 React reconciliation: how it works and why should we care: www.developerway.com/posts/reconciliation-in-react ⃗💬 Twitter: adevnadia 💬 Linkedin: www.linkedin.com/in/adevnadia/ 👩🏼‍💻 The mystery of conditional rendering: codesandbox.io/s/keen-fog-vrujk7?file=/src/App.tsx 👩🏼‍💻 How to fix it with re-positioning: codesandbox.io/s/re-position...
Say no to "flickering" UI: useLayoutEffect, painting and browsers story
zhlédnutí 6KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Say no to "flickering" UI: useLayoutEffect, painting and browsers story: www.developerway.com/posts/no-more-flickering-ui 💬 Twitter: adevnadia 💬 Linkedin: www.linkedin.com/in/adevnadia/ 👩🏼‍💻 simple navigation with useEffect, broken: codesandbox.io/s/simple-responsive-menu-example-ltdx5r 👩🏼‍💻 simple navigation with useLayoutEffect, fixe...
Refs in React: from access to DOM to imperative API
zhlédnutí 3,9KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Refs in React: from access to DOM to imperative API: www.developerway.com/posts/refs-from-dom-to-api 💬 Twitter: adevnadia 💬 Linkedin: www.linkedin.com/in/adevnadia/ 👩🏼‍💻 Simple ref use: codesandbox.io/s/giant-form-ref-example-23z9vf 👩🏼‍💻 Pass ref as a prop: codesandbox.io/s/example2-pass-ref-as-prop-5i03u9 👩🏼‍💻 Pass ref with forwardRef...
The mystery of React key: how to write performant lists
zhlédnutí 4,8KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Comprehensive guide on React re-renders (www.developerway.com/posts/react-re-renders-guide) 👉 How to useMemo and useCallback: you can remove most of them (www.developerway.com/posts/how-to-use-memo-use-callback) 👉 React key attribute: best practices for performant lists (www.developerway.com/posts/react-key-attribute) 💬 Twitter: adevna...
useCallback for re-renders: remove most of them
zhlédnutí 6KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Comprehensive guide on React re-renders (www.developerway.com/posts/react-re-renders-guide) 👉 How to useMemo and useCallback: you can remove most of them (www.developerway.com/posts/how-to-use-memo-use-callback) 👉 The mystery of React Element, children, parents and re-renders (www.developerway.com/posts/react-elements-children-parents) 💬 Twitter: ...
Preventing re-renders with React.memo
zhlédnutí 5KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Comprehensive guide on React re-renders (www.developerway.com/posts/react-re-renders-guide) 👉 How to useMemo and useCallback: you can remove most of them (www.developerway.com/posts/how-to-use-memo-use-callback) 👉 The mystery of React Element, children, parents and re-renders (www.developerway.com/posts/react-elements-children-parents) 💬 Twitter: ...
Preventing React re-renders with composition
zhlédnutí 18KPřed rokem
👉 Advanced React Book: www.advanced-react.com 👉 Comprehensive guide on React re-renders (www.developerway.com/posts/react-re-renders-guide) 👉 How to useMemo and useCallback: you can remove most of them (www.developerway.com/posts/how-to-use-memo-use-callback) 👉 The mystery of React Element, children, parents and re-renders (www.developerway.com/posts/react-elements-children-parents) 💬 Twitter: ...
Why React components re-render?
zhlédnutí 13KPřed rokem
Why React components re-render?

Komentáře

  • @shrikantjha5630
    @shrikantjha5630 Před 18 hodinami

    Helpful

  • @anwarbaig8037
    @anwarbaig8037 Před 2 dny

    I can’t thank you enough for these tutorials. They’ve been a huge help in my learning process. Your dedication to teaching is truly appreciated!

  • @couragic
    @couragic Před 3 dny

    I like your voice. Looking forward for the next lesson.

  • @ghostrAider98
    @ghostrAider98 Před 4 dny

    Thank you. Probablythe best way of teaching an optimization technique and it's core underlying principle and closures I've seen. Rare quality content

  • @mj2068
    @mj2068 Před 6 dny

    this video is epiphanic🤯. laterally. i epiphany-ed when you showed `children` is `content` just another name plus jsx sugar, and the 3 heavies are created in App scope passed as arguments to Scrollable... thank you soso much. incredible

  • @hamzahahmad1670
    @hamzahahmad1670 Před 6 dny

    Thank you for all your efforts in these videos! I purchased the digital version of your book, but I find it much easier to learn things when they are in a video format. These videos are amazing resources

  • @raminkhodaie4063
    @raminkhodaie4063 Před 7 dny

    What if I set the open modal flag in a global state such as zustand? does the App component will rerendered in this case too?

  • @anwarbaig8037
    @anwarbaig8037 Před 13 dny

    Ma'am,your video are best.

  • @K.Huynh.
    @K.Huynh. Před 17 dny

    so cool, thank you for sharing!

  • @ChikiCodes
    @ChikiCodes Před 23 dny

    amazing video......learnt a lot from your story telling teaching style

  • @oussahadd
    @oussahadd Před 23 dny

    Awesome content, thank you very much !

  • @hannahpun
    @hannahpun Před měsícem

    Thanks for sharing , it's really helpful

  • @thiagomasseno2550
    @thiagomasseno2550 Před měsícem

    There's something i didn't get ... is about the moment on your video "time 3 minutes and 49 seconds" i have a doub . The value i need to put into the property ref = " " in a tag <input > have must to be the same name of variable who has the useRef() at the line 3 from the code on the video ?

  • @bogdanvoicescu4746
    @bogdanvoicescu4746 Před měsícem

    Your videos are awesome. Your voice is really nice and I like the calm and friendly way you talk. It's the kind of thing I can watch at home after a day's work and not get more tired. The videos are really easy to understand. Don't stop making these videos, I'm learning a lot.

  • @hamidhamri5384
    @hamidhamri5384 Před měsícem

    you should be on react team <3

  • @pranayahirwar
    @pranayahirwar Před měsícem

    I really really like your explanation, the time you have put in to make these videos and the cat sticker, it's really cute specially the cat with crown. Wishing you success in getting what you desire.

  • @dmtrack
    @dmtrack Před měsícem

    brilliant ❤ I’m watching it after reading particular part of your book. Thank you very much! Is there any possibilities to support your work ?

    • @developerwaypatterns
      @developerwaypatterns Před měsícem

      Buying the book and spreading the word about it is a great support! ❤️

  • @notcountdankula
    @notcountdankula Před měsícem

    Wow. So grateful for this video. 🙏

  • @GurovDmitriy
    @GurovDmitriy Před měsícem

    czcams.com/video/-UjbTFc9NL4/video.html&ab_channel=TannerLinsley

  • @GurovDmitriy
    @GurovDmitriy Před měsícem

    components cannot be created inside components... unless it's a memo))))

  • @niteshrathore4341
    @niteshrathore4341 Před měsícem

    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 Před měsícem

    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 Před měsícem

    The best blogger ever! I want your next.js course to watch next

  • @boyywnkobe
    @boyywnkobe Před měsícem

    3:31 у вас помилка, має бути false a є true в субтитрах

  • @mariolazzari
    @mariolazzari Před měsícem

    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 Před měsícem

    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 Před měsícem

      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 Před měsícem

      @@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 Před měsícem

      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 Před měsícem

      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 Před měsícem

      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 Před měsícem

    im really curious about the software you use to create the code animations, would you be so kind to share it?

    • @developerwaypatterns
      @developerwaypatterns Před měsícem

      Code animations in Keynote, the rest of them usually in Final Cut Pro or again Keynote

  • @drrodopszin
    @drrodopszin Před měsícem

    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 Před měsícem

    perfect!!!

  • @drrodopszin
    @drrodopszin Před měsícem

    I usually see HoCs in plain Javascript and it makes me worried if it is hard to type correctly and elegantly in TypeScript.

  • @paulstelian97
    @paulstelian97 Před měsícem

    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 Před měsícem

    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 Před měsícem

    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 Před měsícem

    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 Před měsícem

      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 Před měsícem

    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 Před měsícem

    hey, I couldn't reproduce the example "Intercepting DOM events". I've tried several approaches, but it didn't work.

  • @rishabhmishra9611
    @rishabhmishra9611 Před měsícem

    is it just me who is enjoying this series more than any Hollywood series?? great explanations and narration also 👌

  • @ravneetsinghanand1589
    @ravneetsinghanand1589 Před měsícem

    Amazing course! Thank you 🙏

  • @florenciobritez5521
    @florenciobritez5521 Před měsícem

    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 Před měsícem

      Yep, unless you're doing something async there in useeffect IIRC

    • @florenciobritez5521
      @florenciobritez5521 Před měsícem

      @@developerwaypatterns Thank you for responding and for sharing your knowledge with us!

  • @omak3313
    @omak3313 Před měsícem

    Спасибо! Очень полезно! Будет обновление курса и книги после релиза React 19? Собираюсь купить вашу книгу)

  • @mostinho7
    @mostinho7 Před měsícem

    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 Před měsícem

    You explain so well, love it 😅

  • @21agdmnm
    @21agdmnm Před měsícem

    Bought your book after watching some of your videos, you explain so well!

  • @drrodopszin
    @drrodopszin Před měsícem

    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 Před měsícem

      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 Před měsícem

    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 Před měsícem

    This video has helped me a lot to learn more about React.memo. Thanks

  • @omprakashdeshmukh9850
    @omprakashdeshmukh9850 Před měsícem

    Hi Developer, you are creating the best videos, please create videos for JavaScript as well.

  • @mostinho7
    @mostinho7 Před měsícem

    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 Před měsícem

    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.

  • @mj2068
    @mj2068 Před měsícem

    thank you very very much for this.