It was a great tutorial. thanks a lot ... please list this playlist on you main page.
@danielEpifanov3 жыл бұрын
very clear!
@fullstackcraft3 жыл бұрын
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?
@TechbaseDev3 жыл бұрын
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 :)
@vishistsd3 жыл бұрын
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.
@TechbaseDev3 жыл бұрын
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!
@sIvEeodCSIFIjGz2 жыл бұрын
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