Tap to unmute

React Course - TypeScript - Enums

  Рет қаралды 8,678

Techbase

Techbase

Күн бұрын

Пікірлер: 10
@YiannisChristodoulou
@YiannisChristodoulou 3 жыл бұрын
Nice example, thanks!
@miloman1995s
@miloman1995s 2 жыл бұрын
that's what i was looking for , thx!
@hoomtal
@hoomtal 2 жыл бұрын
It was a great tutorial. thanks a lot ... please list this playlist on you main page.
@danielEpifanov
@danielEpifanov 3 жыл бұрын
very clear!
@fullstackcraft
@fullstackcraft 3 жыл бұрын
Regardless of using enums or union types... you essentially render the same button three times, where the only thing that changes is onClick the callback. Why don't you declare the callback signature based on the enum value? Also, when using an enum you ALWAYS use a switch case - so you can use the default case properly. Otherwise, what happens when you add a new member to your enum?
@TechbaseDev
@TechbaseDev 3 жыл бұрын
For the sake of simplicity I preferred to duplicate (copy / paste) the buttons, but this would indeed not be the preferred way in a real world app. I'm not quite sure if I understand you correctly with regards to using a switch case with enums; if you find some time to describe it in more detail: please do so :)
@vishistsd
@vishistsd 3 жыл бұрын
I think the explanation against enums wasn't enough in this video. For something as simple as this, replacing string literals with values, it is better to use enums, however, there might be use cases where enums might cause some type issues, certainly not here.
@TechbaseDev
@TechbaseDev 3 жыл бұрын
In this example one could've used enums or union types, without major differences. However: - enums are not type-safe when you don't set string values. - enums chose to be named types (thus you can not set it by using a string). For the sake of consistency I recommend people to stick with one approach; you can never go wrong with union types, which can't be said for enums. I recommend you to read the following article (and will put it in the description as well): fettblog.eu/tidy-typescript-avoid-enums Thanks!
@sIvEeodCSIFIjGz
@sIvEeodCSIFIjGz 2 жыл бұрын
usually I like to embrace whatever technology I choose to adopt, so I will give enum a try and try to get familiar with their quirks. let's see how that goes
@richardmelkonian5681
@richardmelkonian5681 3 жыл бұрын
shippin'
React Course - TypeScript - Generic Components
8:18
Techbase
Рет қаралды 11 М.
React Course - TypeScript - useState
11:20
Techbase
Рет қаралды 15 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
TypeScript Tutorial #19 - Enums
3:25
Net Ninja
Рет қаралды 87 М.
Type useContext : React and TypeScript
17:00
Atila
Рет қаралды 15 М.
You Must Know This Awesome Typescript Library - Typia Tutorial
13:29
Albion Online BEST Silver Farming Methods!
10:15
R3io
Рет қаралды 29
TypeScript Type Narrowing with React
12:11
Techbase
Рет қаралды 6 М.
Mastering React Hooks with Typescript
55:12
Jack Herrington
Рет қаралды 101 М.
The best tools for React Developers
9:00
Techbase
Рет қаралды 3,1 М.
React Course - Typescript - Intro
10:35
Techbase
Рет қаралды 55 М.
React Course - TypeScript - Context API
7:09
Techbase
Рет қаралды 14 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН