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.
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?
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.
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.
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.
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.
Arrow functions are not hoisted, so you cannot use them before initialization, that's why you used regular functions
insightful, thank you
@augustopruvost7316 Thank you so much 🙏.
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.
Thanks, 😊🌹, really happy you enjoyed it. Yes I put it on my list.
Thanks for the video man, really helped me to accomplish this pattern.
Welcome to the channel🖐🏻, Glad it helped!
we used primitive functions because we can't call arrow functions before initialization?
Thats true. mamnoon
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?
Yes it is possible. here is an example: github.com/vahid-nejad/medical-evaluator-tooth/blob/main/src/components/elements/DataTable.tsx
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
Glad you found my videos useful.
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.
Great explanation 👏🏻👏🏻
Thanks, I hope it was helpful for you 🌷
because of temporal dead zone. Arrows functions are a bad idea when you want to avoid it.
The compound-component React Pattern, so clearly explained. Thank you.
{2024-06-10}
Awesome 👏👏👏
Thanks for your nice response 🙏🙏
Thanks but I don't understand why the second method is a better practice, it looks more difficult and complex....
Hi. It move the complexity inside the component. you define the complex code once and use it multiple time.
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.
@@liu-river thanks for your nice explanation
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.
Btw, your method looks more organic than the other video.
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
its bad pattern lol
tree shaking leave from chat
Reason?
@@galactusclb5733 bundlers cant optimize unused namespace import from dot
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.
clowns