Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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

57,741 Aufrufe • vor 2 Jahren •via X (Twitter)

10 Kommentare

Profilbild von George Moller
George Mollervor 2 Jahren

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 ↓

Profilbild von Julius
Juliusvor 2 Jahren

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

Profilbild von George Moller
George Mollervor 2 Jahren

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

Profilbild von freddie
freddievor 2 Jahren

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…

Profilbild von George Moller
George Mollervor 2 Jahren

ChangeInputEvent, ChangeTextAreaEvent, there you go now...

Profilbild von harpaljadeja.eth (evm/acc) 🇮🇳
harpaljadeja.eth (evm/acc) 🇮🇳vor 2 Jahren

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

Profilbild von Rodwell Leo
Rodwell Leovor 2 Jahren

Everyday I learn something new from you. Thank you 🙏

Profilbild von George Moller
George Mollervor 2 Jahren

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

Profilbild von Hassan
Hassanvor 2 Jahren

👍👍👍

Profilbild von Karl R.
Karl R.vor 2 Jahren

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.

Ähnliche Videos