Thanks for sharing. I recently learned about getters/setters. While it is a good concept in terms of OOP, I wonder if there is a use case in the React ecosystem. I would like to hear your thoughts on that.
First: It's good to know how it works under the hood but today you can just use es6 classes and with typescript you dont need to check the type yourself. Just define the input a string.
Second: Whenever you need a a combination of values a getter is usefull. For example a component has 2 attributes. One const for MAX_ENTRIES and another one for an array entries. The getter would be smth like entriesLeft and returns MAX_ENTRIES - entries.length.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for sharing. I recently learned about getters/setters. While it is a good concept in terms of OOP, I wonder if there is a use case in the React ecosystem. I would like to hear your thoughts on that.
First: It's good to know how it works under the hood but today you can just use es6 classes and with typescript you dont need to check the type yourself. Just define the input a string.
Second: Whenever you need a a combination of values a getter is usefull. For example a component has 2 attributes. One const for MAX_ENTRIES and another one for an array entries. The getter would be smth like entriesLeft and returns MAX_ENTRIES - entries.length.