JSX.Element vs React.ReactNode

  Рет қаралды 39,053

Matt Pocock

Matt Pocock

4 ай бұрын

Пікірлер: 21
@mohammadaminmemarzadeh45
@mohammadaminmemarzadeh45 4 ай бұрын
Jsx.element is literally jsx element
@Thassalocracy
@Thassalocracy 4 ай бұрын
In set terms, JSX.Element is a subset of React.ReactNode.
@lukasmolcic5143
@lukasmolcic5143 4 ай бұрын
thank you, this makes perfect sense since there is un underlying type difference in html itself where Element is a type of a dom Node
@orderandchaos_at_work
@orderandchaos_at_work 4 ай бұрын
Thanks for this. Drives me crazy when people get this wrong.
@mosescosme8629
@mosescosme8629 4 ай бұрын
I learned this the hard way with layout components.
@coolmind2476
@coolmind2476 Ай бұрын
Why react developers dont extend the definition of JSX.Element to include strings or Numbers? Why to have separate type reactnode?
@otiamaino2461
@otiamaino2461 Ай бұрын
Weird if they learnt js this shouldn’t be a problem I mean DOM nodes are anything from a tag to a text, and HTMLElements are html tags 🤲🏾
@shapelessed
@shapelessed 4 ай бұрын
So... A React.ReactNode is essentially just anything that's valid HTML like strings and numbers, where JSX.Element is just JSX which must include a parent tag or ... Got it
@willi1978
@willi1978 4 ай бұрын
don't trust people touching the screen with fingers
@user-gv9tt5un9f
@user-gv9tt5un9f 4 ай бұрын
Perfectly right
@christianflores3437
@christianflores3437 4 ай бұрын
Uh huh me scrolling through wishing i can code in a job
@gubatenkov
@gubatenkov 4 ай бұрын
dude froze indoors
@ophirbucai
@ophirbucai 4 ай бұрын
Null can be considered a ReactNode too
@mattpocockuk
@mattpocockuk 4 ай бұрын
Yep!
@BlurryBit
@BlurryBit 4 ай бұрын
heh so I have been using element: Element | string | number where I could just have used element: ReactNode 😮 Noted sir! 😊
@robertsandiford6223
@robertsandiford6223 4 ай бұрын
ReactNode can also be null, boolean and and I think undefined or an array of nodes.
@BlurryBit
@BlurryBit 4 ай бұрын
@@robertsandiford6223 Yes for sure. Point being that all of the ones in the original comment could have been covered by ReactNode.
@robertsandiford6223
@robertsandiford6223 4 ай бұрын
@@BlurryBit Yep I agree. Depends whether you want those extra types in there though? Types are not just to make squigglies to go away, but also to catch mistakes, right?
@BlurryBit
@BlurryBit 4 ай бұрын
@@robertsandiford6223 catch mistakes while typing, absolutely! In most cases I need the element, or a string. Even number is not needed in 90% of these cases. For something more narrow, Element could be used.
@brokeloser
@brokeloser 4 ай бұрын
Where did the shiny dome go?
@mattpocockuk
@mattpocockuk 4 ай бұрын
Under the sheath
8 TypeScript Tips To Expand Your Mind (and improve your code)
10:54
Enums considered harmful
9:23
Matt Pocock
Рет қаралды 194 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 6 МЛН
Final muy inesperado 🥹
00:48
Juan De Dios Pantoja
Рет қаралды 18 МЛН
Watermelon Cat?! 🙀 #cat #cute #kitten
00:56
Stocat
Рет қаралды 52 МЛН
Backstage 🤫 tutorial #elsarca #tiktok
00:13
Elsa Arca
Рет қаралды 47 МЛН
Turning bad React code into senior React code
13:10
Cosden Solutions
Рет қаралды 86 М.
Most React devs don’t understand generic components
5:43
Matt Pocock
Рет қаралды 46 М.
Learn nested interfaces in typescript within 2 minutes 🙂🚀!
3:11
TypeScript 5.5 is a BANGER
9:16
Matt Pocock
Рет қаралды 50 М.
Tuples in typescript
9:53
Hitesh Choudhary
Рет қаралды 10 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 164 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 416 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 550 М.
The Carbonaro Effect - Man-Eating Pig Revealed
5:44
truTV
Рет қаралды 2,2 МЛН
Never Forget React forwardRef Again
9:33
Coding in Public
Рет қаралды 14 М.
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,8 МЛН
После ввода кода - протирайте панель
0:18