Compound Components are SUPER intuitive

preview_player
Показать описание
#shorts

Become a TypeScript Wizard with my free beginners TypeScript Course:

Follow Matt on Twitter

Join the Discord:

Рекомендации по теме
Комментарии
Автор

Can you make a video on using compound components and forwardRef together?

stevecastaneda
Автор

Why are you calling us Wizards? Can you call us Barbarians sometimes? Not all of us coders like spell casting, some of us like melee :)

joseandkris
Автор

Setting function properties can be pretty useful in some situations. Say you want to store some metadata or use a callback function differently based on a property.

In this case though I don't really see the benefit. Wouldn't it be better to just define/import those components separately? Looser coupling and better for treeshaking I'd imagine..

codebycarlos
Автор

hey man, thank you for these short videos. I love to start my day learning some random unknown thing from typescript that I can easily try on my work (unknown for me at least)

Fingolfin
Автор

why exactly is <Form.Input> superior to just using <Input> inside <Form>?

yavuz
Автор

Hi Matt! What about compound with forwardRef? A quick video maybe please? 😊

clementcreusat
Автор

Why would you do that though? What problem does it solve?

yadusolparterre
Автор

You can also use Object.assign(Form, {Input})

MauroGabrielTitimoli
Автор

You are so good man ❤❤❤ Awasome tutorial..

umargulzar
Автор

I've seen this pattern before and it's very lovely to use. Would love to have this pattern available in other frameworks/libraries too

baka_baca
Автор

Hey Matt, what would be even more interesting with compound components is to restrict the type of child component. In this example the `Form` component can only contain `Form.Input` components

mickaelmarques
Автор

I’ve seen this used for react-bootstrap, nice trick

Meuhandle
Автор

But why would I want a compound component?

DaminGamerMC
Автор

Nice post matt, although I think the text is a wee bit small.

Meuhandle
Автор

Apart from the semantics, what use cases for it you see, Matt?

stopster
Автор

So is this possible because Typescript performs type-narrowing after every assignment statement?

vikingthedude
Автор

I've not seen this pattern used in react in years lol

sc
Автор

thit is only setting a property on function object, not specific to typescript feature, it is purely javascript magic, right?

DioArsya
Автор

Hmm, i used to use
```
const Form = Object.assign(() => ..., { Input })
```

nazarshvets
Автор

Personally would've just named it FormInput to show association. But there might be some better use cases for it that Idk about

re.liable