React Components with GENERICS? - Advanced TypeScript

preview_player
Показать описание
Become a TypeScript Wizard with Matt's upcoming TypeScript Course:

Follow Matt on Twitter

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

Also found that adding a comma after the generic arg allows you to still use arrow functions

nick
Автор

You can use generic with an arrow function in jsx. To do so use next: <T, >
(with comma at the end)

alexandercherniavenko
Автор

Thank you Matt. These bite sized videos on more specific and localised topics are great. Keep them coming!

PrevalentAA
Автор

Very nice.
This is now accepted too btw (0:37)

workflowinmind
Автор

Brillant! Really helpful for typing mu custom data table component. Great job!

mariolazzari
Автор

Absolute lifesaver, thank you so much

TheMERABANABER
Автор

You can also just use <T extends any>() => to make it not ambigious in tsx files

williamcory
Автор

Thanks for sharing your knowledge 👍🏾
You can use this <T extends { id: number } >

amirbagjani
Автор

am I only the one who is confused by the 'renderItem' prop? I mean it's just a prop, meanwhile Table returns nothing - if prop isn't executed from the component it won't get executed. so what's the point ?

vasylnekohda
Автор

how will it looks like if i need wrap my component in forwardRef?

sergeymild
Автор

how can we use generics for forwardRef type

NareshKumarPanneerSelvam
Автор

I find your videos very cool! But it would be even cooler if you took a small js lib and taught generics by adding types to it, on real word example)

ГерриПитт
Автор

You dont need to turn it into function, const is fine but use extends instead

archmad
Автор

but be carefull since it's easy to lose type-safety with this approach

jeffnikelson