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

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 34

  • @JairoPy
    @JairoPy 10 місяців тому +15

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

  • @SimPwear84
    @SimPwear84 Рік тому +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  Рік тому

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

  • @giovannitonussi3746
    @giovannitonussi3746 Рік тому +2

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

    • @SakuraDev
      @SakuraDev  Рік тому +1

      Welcome to the channel🖐🏻, Glad it helped!

  • @alirezak5870
    @alirezak5870 Рік тому +5

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

  • @einfacherkerl3279
    @einfacherkerl3279 6 місяців тому

    i have a question. if i want to have a generic component, let's say a grid. and the generic argument is the data that is passed to the grid which off course is a list of rows with each row having same columns. i want the child component, a grid column to bind to a particular column of the data. how is it possible?

    • @SakuraDev
      @SakuraDev  6 місяців тому

      Yes it is possible. here is an example: github.com/vahid-nejad/medical-evaluator-tooth/blob/main/src/components/elements/DataTable.tsx

  • @0xtz_
    @0xtz_ Рік тому +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  Рік тому +1

      Glad you found my videos useful.

    • @giovannitonussi3746
      @giovannitonussi3746 Рік тому

      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.

  • @xiiEJRAM
    @xiiEJRAM Рік тому +1

    Great explanation 👏🏻👏🏻

    • @SakuraDev
      @SakuraDev  Рік тому

      Thanks, I hope it was helpful for you 🌷

  • @ThugLifeModafocah
    @ThugLifeModafocah Рік тому

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

  • @Pareshbpatel
    @Pareshbpatel 7 місяців тому

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

  • @raphauy
    @raphauy Рік тому

    Awesome 👏👏👏

    • @SakuraDev
      @SakuraDev  Рік тому

      Thanks for your nice response 🙏🙏

  • @mediacreatif
    @mediacreatif Рік тому

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

    • @SakuraDev
      @SakuraDev  Рік тому

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

    • @liu-river
      @liu-river Рік тому

      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  Рік тому

      @@liu-river thanks for your nice explanation

  • @Edwinil
    @Edwinil Рік тому +1

    Hi, is there a different between composition component(ua-cam.com/video/vPRdY87_SH0/v-deo.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 Рік тому

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

    • @SakuraDev
      @SakuraDev  Рік тому

      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_ Рік тому +2

    its bad pattern lol
    tree shaking leave from chat

    • @galactusclb5733
      @galactusclb5733 Рік тому

      Reason?

    • @popuguytheparrot_
      @popuguytheparrot_ Рік тому

      @@galactusclb5733 bundlers cant optimize unused namespace import from dot

    • @KarimShalapy
      @KarimShalapy 7 місяців тому

      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_ Рік тому

    clowns