Loading video...

Video Failed to Load

Go Home

React.ComponentProps is such a lifesaver, and more folks need to know about it.

106,589 views • 3 years ago •via X (Twitter)

10 Comments

Seb ⚛️ ThisWeekInReact.com's profile picture
Seb ⚛️ ThisWeekInReact.com3 years ago

😄 Basically impossible to work with React + TypeScript without this This is my most upvoted SO answer btw

Matt Pocock's profile picture
Matt Pocock3 years ago

Nice!

Chris Ribeiro's profile picture
Chris Ribeiro3 years ago

Is it work with forwardRef?

Sadman Sakib's profile picture
Sadman Sakib3 years ago

you can also create type for framer motion div this way

Sidi jeddou's profile picture
Sidi jeddou3 years ago

Wow wow I really didn’t know about this, thank you so much, Matt.

nexxel's profile picture
nexxel3 years ago

wow this is so helpful

Marcos S. 🇵🇸 | tpicj index.js's profile picture
Marcos S. 🇵🇸 | tpicj index.js3 years ago

`React.ComponentProps<typeof Component>`: exists. Me: `Parameters<typeof Component>[number]`. I just keep forgetting about it.

guido scialfa's profile picture
guido scialfa3 years ago

Thanks for sharing that. Most of the time we tend to write our own times when what we need is already there XD

scarletczen🌃's profile picture
scarletczen🌃3 years ago

This is actually really good. I either write or use some library to get these props lol.

Josh Claunch's profile picture
Josh Claunch3 years ago

I've always wished we had a good naming convention for generic extractors like this. Doing <type-name><generic-name> like `ComponentProps` is too ... generic 😄

Related Videos