❤️ The React Pattern I Don't Want To Miss!

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.ค. 2023
  • In this informative and practical video, we delve into the fascinating world of React compound component pattern and explore how it can dramatically enhance the cleanliness and maintainability of your code. As developers, we strive to write clean, modular, and reusable code, and the compound component pattern provides an elegant solution to achieve just that in your React projects.
    Throughout the video, we'll demystify the concept of compound components and demonstrate step-by-step how to implement them effectively. You'll gain a deep understanding of how compound components work together, allowing you to create highly customizable and flexible UI components in React. By leveraging this powerful pattern, you'll be able to build complex user interfaces while keeping your codebase organized and easy to understand.
    ------------------------------------------------------------------------------------
    GitHub Repo(Don't forget to give it a star): github.com/vahid-nejad/React-...
    #React.js #nextjs #CleanCode

ความคิดเห็น • 30

  • @JairoPy
    @JairoPy 3 หลายเดือนก่อน +6

    Arrow functions are not hoisted, so you cannot use them before initialization, that's why you used regular functions

  • @SimPwear84
    @SimPwear84 11 หลายเดือนก่อน +4

    Beautifully explained!! Enjoyed this video a lot and just subscribbed.
    Can you please make more videos on React design patterns? You do it very well, thanks.

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Thanks, 😊🌹, really happy you enjoyed it. Yes I put it on my list.

  • @alirezak5870
    @alirezak5870 11 หลายเดือนก่อน +5

    we used primitive functions because we can't call arrow functions before initialization?

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Thats true. mamnoon

  • @Pareshbpatel
    @Pareshbpatel 19 วันที่ผ่านมา

    The compound-component React Pattern, so clearly explained. Thank you.
    {2024-06-10}

  • @giovannitonussi3746
    @giovannitonussi3746 10 หลายเดือนก่อน +2

    Thanks for the video man, really helped me to accomplish this pattern.

    • @SakuraDev
      @SakuraDev  10 หลายเดือนก่อน +1

      Welcome to the channel🖐🏻, Glad it helped!

  • @raphauy
    @raphauy 11 หลายเดือนก่อน

    Awesome 👏👏👏

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Thanks for your nice response 🙏🙏

  • @ThugLifeModafocah
    @ThugLifeModafocah 6 หลายเดือนก่อน

    because of temporal dead zone. Arrows functions are a bad idea when you want to avoid it.

  • @xiiEJRAM
    @xiiEJRAM 11 หลายเดือนก่อน +1

    Great explanation 👏🏻👏🏻

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Thanks, I hope it was helpful for you 🌷

  • @0xtz_
    @0xtz_ 11 หลายเดือนก่อน +1

    i tried this in next.js 13 idk it dosdent work hh mainly it was types error, now gonna try this and thanks man u always saving my life hhh

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน +1

      Glad you found my videos useful.

    • @giovannitonussi3746
      @giovannitonussi3746 10 หลายเดือนก่อน

      Hello friend, I also had some Typescript errors to create a Compound Table. What saved me was to change all typing to the amazing ComponentProps, imported from React. You just have to pass the Html tag like this: ComponentProps. Worked like a charm. Hope it helps.

  • @mediacreatif
    @mediacreatif 11 หลายเดือนก่อน

    Thanks but I don't understand why the second method is a better practice, it looks more difficult and complex....

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Hi. It move the complexity inside the component. you define the complex code once and use it multiple time.

    • @liu-river
      @liu-river 11 หลายเดือนก่อน

      It's basically a reusable component, you can do the same by using the first pattern and just pass in the content as arguments. But then you can't really read the component and it's content until you open up the component file, this shows you exactly what the component contains. It's up to you how you wanna do it, each to their own.

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      @@liu-river thanks for your nice explanation

  • @Edwinil
    @Edwinil 11 หลายเดือนก่อน +1

    Hi, is there a different between composition component(th-cam.com/video/vPRdY87_SH0/w-d-xo.html) and compound component? Can we use context API in both? The main function CompoundCard can share props with anothers children functions?
    Thanks for the video.

    • @Edwinil
      @Edwinil 11 หลายเดือนก่อน

      Btw, your method looks more organic than the other video.

    • @SakuraDev
      @SakuraDev  11 หลายเดือนก่อน

      Hi, It's slightly different. in compound pattern the children a CARD are specific to the parent and can't be used outside of the parent

  • @popuguytheparrot_
    @popuguytheparrot_ 7 หลายเดือนก่อน +1

    its bad pattern lol
    tree shaking leave from chat

    • @galactusclb5733
      @galactusclb5733 7 หลายเดือนก่อน

      Reason?

    • @popuguytheparrot_
      @popuguytheparrot_ 7 หลายเดือนก่อน

      @@galactusclb5733 bundlers cant optimize unused namespace import from dot

    • @KarimShalapy
      @KarimShalapy 19 วันที่ผ่านมา

      I was just going to comment something similar, now whenever you import the CompoundCard all of its parts are imported with it and it's not shakeable even if you didn't use these parts.
      It could be enhanced by simply exporting all the parts without making it compound but then this would be a children-first component not a compound component.
      I am not sure if I am right or wrong, but this feels wrong.

  • @popuguytheparrot_
    @popuguytheparrot_ 7 หลายเดือนก่อน

    clowns