How to type React events with TypeScript

preview_player
Показать описание

What type to use for your React event handlers if you use TypeScript

Рекомендации по теме
Комментарии
Автор

Heu?! I think there's a way-way easier method to know what a function or method (or any type) is returning, in this case onChange... Hover over the word onChange, and it should show up. If it doesn't, select it and then press ctrl-k, ctrl-i . This works for everything! So if you're calling a function, and you're not sure what signature it has, just select it, and press ctrl-k, ctrl-i. (And there is some additional help: sometimes, when you want to know what options you have to add in as a parameter or attributes there are on an object, just press ctrl-space at the spot where you want to type, and it will come up with the best answer... Well, if you did your best at typing your stuff...) (Actually the hardest part is to know how to read the all those types)

jornejongsma
Автор

Thank you Maxim, I have been waiting for TypeScript series for a long time. I hope this will become a regular thing.

Elator
Автор

Thanks Maksim, this is what i’ve been looking for

me-ynmn
Автор

Максим, спасибо за видео, добра и развитие каналу!
Приятно на английском смотреть, развиваю его на слух.
Добавляю, попробовал, все работает!!Спасибо еще раз, жпт который грозился нас заменить, не заменил Максима:D
Have a nide day!

zzeepps
Автор

Good information. And how to use one event handler for multiple event types if I dont want to duplicate code in seperate event handlers but implement a generic handler?

coolmind
Автор

Thanks for this.

I'm still getting my head wrapped around Typescript in React. The conversion from es6 has been... difficult. Things that just work (like spreading props into a component) is a real PITA in Typescript.

tgoyer
Автор

1:07 what did you click to display the dropdown to import the ChangeEvent?

shafiemukhre
Автор

Really I am too much tried with TypeScript event type.
Thanks you so much times

mdhasanuzzaman
Автор

Коротко и ясно, без воды.
Прекрасный ролик

jullpic
Автор

Awesome stuff thank you!
What i don't get about typescript is, why bother? Adding types to stuff just feels like extra steps?
And it's just one extra thing to Google in addition to potential logical problems or other frameworks or whatever.
I've asked my teacher but he hasn't managed to convey the benefits of typescript

ThunderstruckElectronix
Автор

Should I use typescript in my next projects?

Aoubaker
Автор

I see you're using the Vim extension, would appreciate it a ton if you could do a tutorial about that!
Most posts and videos online just cover the basic navigation keys (h, j, k, l and e b w) and not the combos and other possibilities as much! (yap, yip, ciw, caw etc.)
Whilst that's good too, Vim shines more once you know the combos and all the quick tips/tricks you can do with it, in my opinion.

wandrease
Автор

So to type a simple function I have to type another function look at its properties and then delete it and then write it in accordance with that property or else go into the source of it and find it among 12000 lines of code and close the page and then type it back? How is this even applicable in real life?

mrkhoros
Автор

Pls make a 1hr long tutorial of react and typescript in 2021 pls bro you would get so many views

perc-ai
welcome to shbcf.ru