正在加载视频...

视频加载失败

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

106,584 次观看 • 3 年前 •via X (Twitter)

10 条评论

Seb ⚛️ ThisWeekInReact.com 的头像
Seb ⚛️ ThisWeekInReact.com3 年前

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

Matt Pocock 的头像
Matt Pocock3 年前

Nice!

Chris Ribeiro 的头像
Chris Ribeiro3 年前

Is it work with forwardRef?

Sadman Sakib 的头像
Sadman Sakib3 年前

you can also create type for framer motion div this way

Sidi jeddou 的头像
Sidi jeddou3 年前

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

nexxel 的头像
nexxel3 年前

wow this is so helpful

Marcos S. 🇵🇸 | tpicj index.js 的头像
Marcos S. 🇵🇸 | tpicj index.js3 年前

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

guido scialfa 的头像
guido scialfa3 年前

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

scarletczen🌃 的头像
scarletczen🌃3 年前

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

Josh Claunch 的头像
Josh Claunch3 年前

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 😄

相关视频