Learn React Generic Components In 6 Minutes

  Рет қаралды 59,310

Web Dev Simplified

Web Dev Simplified

Күн бұрын

Пікірлер: 89
@AcromondX
@AcromondX 2 ай бұрын
I will freak out the day Kyle stops shaking his head while speaking. Good stuff BTW!
@lalithrockz
@lalithrockz 2 ай бұрын
Hey has some Indian in him, I guess.
@AkshayPadinjarethadathil
@AkshayPadinjarethadathil 2 ай бұрын
I can not stop noticing it from now.. 😐
@FrontTech-qu3pe
@FrontTech-qu3pe 2 ай бұрын
@@lalithrockz Hey that explains his coding skills 😂
@annetannet6046
@annetannet6046 21 күн бұрын
I didn’t notice it until I saw your comment LOL BTW, great explanation! Always amazing! Thank you, Kyle!!!
@omega.developer
@omega.developer 2 ай бұрын
Bravo, I learned an advanced topic today. That makes my day. Thanks Kyle bro..🎉
@lifeofcode
@lifeofcode 2 ай бұрын
I do this often lately, its made my code so much more reusable. instead of having strict types for components.
@latanoel
@latanoel 2 ай бұрын
I've been using this approach for a while. But for rare cases where components are reused for different source data types. Nice one Kyle.
@vetrivendhan6122
@vetrivendhan6122 2 ай бұрын
Finally someone speaks my point. I really feel happy here. ❤
@rendezone
@rendezone Ай бұрын
For those negative comments about passing generic, albeit uncommonly necessary, it makes some components more reusable in some instances, where typing isn’t well inferred or conflicting. I admit is rare but it is useful. If you want to avoid your users passing a generic, create multiple components that do it for them
@MrJettann
@MrJettann 2 ай бұрын
It's cool, Kyle! Want to see more advanced tricks and tips in react! But where to use such components? Usually lists contains not only primitive values, but other components and more difficult structure in general?
@shivshankarprasad3427
@shivshankarprasad3427 2 ай бұрын
Thanks for the clarification ❤
@Dameng-nb6wc
@Dameng-nb6wc 2 ай бұрын
Just found the solution: {data.map((d) => ( {getRow(d)} ))} would treat JSX.Element as a single element which can avoid the error of Type 'Element[]' is missing the following properties from type 'ReactElement': type, props, key. thanks kyle ~
@aqibmalik6313
@aqibmalik6313 2 ай бұрын
nice work kyle after a while
@JarheadCrayonEater
@JarheadCrayonEater 2 ай бұрын
From a SSE, please use the convention of "T" before the generic type specifiers. It removes conflicts with other type names and also can be carried over to other languages, since it's widely used.
@prathameshedu
@prathameshedu 2 ай бұрын
i am exporting type IDislikeThis
@WebDevelopmentWithSS
@WebDevelopmentWithSS 2 ай бұрын
Thanks a Lot, Bro.❤❤❤❤❤❤❤❤
@KhaledGhallabPro
@KhaledGhallabPro 2 ай бұрын
My beautiful friend.. I have a problem in one of my files in React because of this wonderful lesson I thought that maybe you have a solution for it.. But I do not know how to send you the file to review it and maybe the problem will be solved. Once again I really appreciate what you do for developers. Thank you
@rohitpraks
@rohitpraks 2 ай бұрын
I’ve always been curious, how much money do you make a year?
@MEZOMEZO2011
@MEZOMEZO2011 Ай бұрын
Why?
@DaliborHomola
@DaliborHomola 2 ай бұрын
Thanks a lot, really helped me ❤
@SeanAlunni
@SeanAlunni 2 ай бұрын
I thought you were clickbaiting with that syntax, It's crazy that you can do that!
@testingaccount-x9b
@testingaccount-x9b Ай бұрын
If this seems weird, please check his other video on generics. It might help you.
@mahoneg
@mahoneg 2 ай бұрын
As an old C++ programmer, I like T from C++ templates. Hmmm I wonder if that is where the T comes from. By the way, Kyle helped me understand React and JS a lot.
@chaunceyphilpot3986
@chaunceyphilpot3986 2 ай бұрын
As some others have stated, please use T as a generic type. It's the universal symbol for it. If you put something like "GenericListType" I'm going to assume that's a real type somewhere.
@mysterry2000
@mysterry2000 2 ай бұрын
No. Won't even use i in my for loops either 😤
@aleksander5298
@aleksander5298 2 ай бұрын
You are retarded or what? Skill issue? There is nothing worse than using dumb one letter symbols for generics, maybe start naming your variables like a or b? 🤡
@mohammadsharifulislam1644
@mohammadsharifulislam1644 2 ай бұрын
Thank you so much bro !!.
@anuragpramanik6095
@anuragpramanik6095 2 ай бұрын
What's the font you are using?
@geforcesong
@geforcesong 2 ай бұрын
How this generic type can work with React.FC? I prefer this way to define the component, but didn't find a way of adding generic. e.g. below is not a valid syntax. export const Editor: React.FC = ({ runId }) => {
@岳川-o1h
@岳川-o1h 2 ай бұрын
The arrow function component uses generic T, you can use it without FC, which is the way I usually use it and just define Props. export const Example: FC = forwardRef((props, ref) => { return ( { // {name: string;age: number;id: string;loves: string[];} console.log(item); }} /> ) }) interface EditorProps { list: T[]; itemCallback: (item: T) => void } export const Editor = ({ list }: PropsWithChildren) => { return ( {list.map((item) => { return {item.id} })} ); };
@nicobost1950
@nicobost1950 2 ай бұрын
if you squint your eyes, you can see that Kyle from 5 years ago traveled forward in time and made this video, that's why he hasn't aged a single minute
@tbm1895
@tbm1895 2 ай бұрын
Good explanation : )
@Nusab33
@Nusab33 2 ай бұрын
Hey Kyle, do you have a discord server? The one given in the description is expired.
@ValentinJasonGaje
@ValentinJasonGaje 2 ай бұрын
Can we have more tutorial about Typescript in NextJs or React :)
@parubok
@parubok 2 ай бұрын
Thanks!
@WebDevSimplified
@WebDevSimplified Ай бұрын
You are very welcome!
@Monstermash355
@Monstermash355 2 ай бұрын
Not a fan of at all, there are almost no cases where you need to do this, should have an extended generic instead, or just
@master.sanchit
@master.sanchit 2 ай бұрын
Not even fan of TS infact what is shown in the video as complicated concept actually it's very simple, you can pass key and item in prop it was all not needed IMO. and code will then look simple
@coder_one
@coder_one 2 ай бұрын
I agree - I've been programming for many years in TypeScript and React and have never had the need to combine with generic components according to the KISS principle.
@harleyspeedthrust4013
@harleyspeedthrust4013 2 ай бұрын
@@master.sanchit code will look simple but won't be for the guy who just joined the team and has no idea what type anything is because you didn't use typescript. congratulations, you've just lost hundreds of man-hours because the new guy has much more work to do before he can be productive. never mind the numerous bugs that you introduce every day because you didn't want to use typescript. you've successfully converted a small amount of potential time spent fixing type errors into a large amount of real, billable time spent fixing bugs that were probably seen by customers. by definition code is not simple; if it was then we would all be out of jobs. and yes KISS is important but these days KISS is grossly misunderstood and overapplied in such a way that it resembles the "enterprise" clean code hype of 15 years ago. both KISS and clean code have their gems of wisdom, but if KISS is your only principle and the only thing you care about, then you're doomed to write fragile code that either doesn't work or can't be extended. and there's little worse than a developer who thinks everything is or should be super simple - this kind of developer can drastically slow an otherwise productive team.
@allone258
@allone258 2 ай бұрын
@@master.sanchit and maintenance hell right?
@chidiorji
@chidiorji 2 ай бұрын
I did find that pattern very helpful when building reusable select components with react-select. It allows to pass the actual type of data you want to send to the generic selector component
@Dameng-nb6wc
@Dameng-nb6wc 2 ай бұрын
Thanks for sharing, but I got this error: Type 'Element[]' is missing the following properties from type 'ReactElement': type, props, key. May I ask for some help?
@yatinarora1252
@yatinarora1252 2 ай бұрын
Did you followed the same code
@Dameng-nb6wc
@Dameng-nb6wc 2 ай бұрын
Hi ​@@yatinarora1252 I just provided my potential solution below.
@Shyam_Mahanta
@Shyam_Mahanta 2 ай бұрын
Nice one 👍
@viet.khoaiegg
@viet.khoaiegg 2 ай бұрын
Thanks a lot, now I can get rid any haha
@akinloludavid3
@akinloludavid3 2 ай бұрын
never seen anything like this before
@evalaviniabucur1789
@evalaviniabucur1789 2 ай бұрын
I'm just curious who Sally is :))
@vivekkaushik9508
@vivekkaushik9508 2 ай бұрын
Prob his girlfriend. You jealous? 😝
@evalaviniabucur1789
@evalaviniabucur1789 2 ай бұрын
@@vivekkaushik9508 he's married, from what I remember. But, yes, I was actually asking if that's his wife's name :P
@adityaanuragi6916
@adityaanuragi6916 2 ай бұрын
Yea I was wondering the same, I've seen him use Kyle and Sally many times before, I think it's his wife's name but I could be very wrong
@WebDevSimplified
@WebDevSimplified 2 ай бұрын
It is a random name actually. It was the first name that popped into my head during one of my first videos and now I just always default to using it. I don't even know a Sally.
@evalaviniabucur1789
@evalaviniabucur1789 2 ай бұрын
@@WebDevSimplified thank you! :))
@andrevenancio
@andrevenancio 2 ай бұрын
What if you want to pass an array of different data types? Let’s say an array of components all with different props to render a side panel based on data? I tried generics and couldn’t get it to work 😅
@yatinarora1252
@yatinarora1252 2 ай бұрын
Nice question need to try it tho
@ikbalnayem8914
@ikbalnayem8914 2 ай бұрын
Great
@irfansaeedkhan7242
@irfansaeedkhan7242 2 ай бұрын
i want to buy your course but its too much expensive for 3rd world country , kindly add that feature which gives discount for 3rd world countries if possible, I mostly buy through that, thank you
@WebDevSimplified
@WebDevSimplified 2 ай бұрын
I already have this implemented. All my courses offer PPP discounts to hundreds of countries. If your country qualifies you will see a discount code at the top of the page. If you don't see the code make sure you disable any VPN you have running as that will prevent the code from showing.
@krzysztofrozbicki1776
@krzysztofrozbicki1776 2 ай бұрын
Seems like solution for problem that Typescript created. Longer i use Typescript and plain Js the more i hate Typescript and appreciate the non type of js
@Kairos26
@Kairos26 2 ай бұрын
x2 speed i learned it in 3 mins 😎😎
@unknownguywholovespizza
@unknownguywholovespizza 2 ай бұрын
Old joke 🥱
@thekaka6520
@thekaka6520 2 ай бұрын
Please slowly, take a breath dude relax to explain
@28-huyop93
@28-huyop93 2 ай бұрын
🎉🎉
@coffeemakir1977
@coffeemakir1977 2 ай бұрын
Continually making the code more and more verbose, remembering where and how things are added, oops you forgot one thing spend time figuring it out or look it up. That is what i hate
@teenspirit8714
@teenspirit8714 2 ай бұрын
so u fucked up static typing and you glad of it? grats, bro
@mrsteven7100
@mrsteven7100 2 ай бұрын
Noooo I don’t believe any big open source or component library would use this pattern…
@blackwhitekeys2523
@blackwhitekeys2523 2 ай бұрын
Higher order components How to render text, Radio, select, checkbox, all components dynamically with the help of higher order components?
@gidmanone
@gidmanone 2 ай бұрын
It's not worth it man. Horrible horrible syntax. It interesting that the main use of Typescript is for auto-suggestion in the IDE.
@NoobaLV
@NoobaLV 2 ай бұрын
I’ve commented before but ill just reiterate, this is the most educational modern React channel on the site right now
@vivekkaushik9508
@vivekkaushik9508 2 ай бұрын
Bro, not cool you just deleted my detailed comment explaining and extending the topic. Not very genuine of you. I'm saddened and my night is ruined.
@WebDevSimplified
@WebDevSimplified 2 ай бұрын
I haven't deleted any comment. Most likely KZbin automatically deleted it which happens often with comments containing URLs.
@OCEMTechZone
@OCEMTechZone 2 ай бұрын
Great
Top 6 React Hook Mistakes Beginners Make
21:18
Web Dev Simplified
Рет қаралды 577 М.
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 139 М.
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 7 МЛН
"كان عليّ أكل بقايا الطعام قبل هذا اليوم 🥹"
00:40
Holly Wolly Bow Arabic
Рет қаралды 12 МЛН
The Most Important Skill You Never Learned
34:56
Web Dev Simplified
Рет қаралды 211 М.
Learn Event Delegation In 10 Minutes
9:57
Web Dev Simplified
Рет қаралды 59 М.
Master CSS Overflow/Text Wrapping Like A Senior Developer
20:53
Web Dev Simplified
Рет қаралды 56 М.
Most React devs don’t understand generic components
5:43
Matt Pocock
Рет қаралды 48 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 481 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 273 М.
8 TypeScript Tips To Expand Your Mind (and improve your code)
10:54
This Folder Structure Makes Me 100% More Productive
24:36
Web Dev Simplified
Рет қаралды 33 М.
Learn useActionState In 8 Minutes - React Hooks Simplified
8:44
Web Dev Simplified
Рет қаралды 25 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 179 М.