Загрузка видео...

Не удалось загрузить видео

На главную

⚛️ How to use TypeScript type predicates in React to create a more robust, type-safe, and maintainable component. (this pattern is particularly useful when dealing with discriminated unions or when you need to narrow types based on runtime checks)

29,524 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 5

Фото профиля George Moller
George Moller2 лет назад

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 70+ video tutorials just like this one. Check them out ↓

Фото профиля Andre de Waard
Andre de Waard2 лет назад

We don’t need this since TS 5.5 right?

Фото профиля Prasenjit
Prasenjit2 лет назад

Thank you for the check, it's going to be useful.

Фото профиля Pavel Romanov
Pavel Romanov2 лет назад

Strange, I've just tested it in TS playground and stackblitz React playground and it narrows the type correctly (with the latest TS version). Maybe it is a problem of some older TS version or less strict TS complier config?

Фото профиля Davide Briano
Davide Briano2 лет назад

This is automatically narrowed with the latest TS version now 👌🏻

Похожие видео