React.ComponentProps is such a lifesaver

Опубликовано: 03 Май 2023
на канале: Matt Pocock
67,975
5.8k

In this video, I'll be talking about a type helper in React called ComponentProps, which is especially useful if you're using TypeScript. With ComponentProps, you can pass in any DOM element and get the props for that element, like button props. You can also grab any props from any other component using the typeof keyword, which can come in handy. If you need a ref as well, you can use ComponentPropsWithRef by passing in a DOM element or just any arbitrary components. This helper makes it easy to solve various problems when using React with TypeScript and saves you time and effort.

Become a TypeScript Wizard with my free beginners TypeScript Course:

https://www.totaltypescript.com/tutor...

Follow Matt on Twitter

  / mattpocockuk  

Join the Discord:

https://mattpocock.com/discord


Смотрите видео React.ComponentProps is such a lifesaver онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Matt Pocock 03 Май 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 67,97 раз и оно понравилось 5.8 тысяч людям.