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

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

На главную

⚛️ React + Typescript Tip: How to create short and easy to remember event types with Typescript ↓

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

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

Фото профиля 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 ↓

Фото профиля Julius
Julius2 лет назад

Don't see how this is any easier than react's built-ins..

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

It’s easier to read/maintain because and you have one entry point file in case those types change in react. The only disadvantage of this is that you hide the root type, but that is something I’m willing to accept for the sake of keeping the code “cleaner”.

Фото профиля freddie
freddie2 лет назад

not good, now you have to keep every member of your team aware of your type aliases for saving some characters. And not every event is the same for every element, you’re not obscuring the fact it's a changeEvent for input, not textarea, or form, or button…

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

ChangeInputEvent, ChangeTextAreaEvent, there you go now...

Фото профиля harpaljadeja.eth (evm/acc) 🇮🇳
harpaljadeja.eth (evm/acc) 🇮🇳2 лет назад

Is there a list of all types that are used in React? I always end up looking here and there for different types when I want to combine my custom props object with the html element attributes

Фото профиля Rodwell Leo
Rodwell Leo2 лет назад

Everyday I learn something new from you. Thank you 🙏

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

Thanks mate! really appreciate the support and happy that you like the content :)

Фото профиля Hassan
Hassan2 лет назад

👍👍👍

Фото профиля Karl R.
Karl R.2 лет назад

I do not see a point that would make it easier / cleaner. I totally agree that it makes your component „shorter” though. If I start to work on a new codebase tomorrow, I would not even think that there is a file with such aliases and I would just use built-ins which imo is fine.

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