Video yükleniyor...
Video Yüklenemedi
⚛️ React + Typescript Tip: How to create short and easy to remember event types with Typescript ↓
57,738 görüntüleme • 2 yıl önce •via X (Twitter)
10 Yorum

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 ↓

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

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”.

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…

ChangeInputEvent, ChangeTextAreaEvent, there you go now...

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

Everyday I learn something new from you. Thank you 🙏

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

👍👍👍

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.

