Re:Using TypeScript with React
by azangru on Thursday August 22, 2019 @12:41PM
(#20769900)
This sounds very arbitrary, opinionated, and unconvincing. If a class is a co-location of data and methods performed on it, then how is this class:
any worse than this POJO:
Besides, what are models and controllers in React codebases, and why is using classes for one of these groups any better than for the other?
[ Parent
| on HN ]
Re:Using TypeScript with React
by neurotrace on Thursday August 22, 2019 @02:46PM
(#20771190)
I think you missed the part where they said you don't need classes for POJOs and models i.e. things which only contain data and do nothing else. If you want methods that operate against the inner data of an object then totally write classes
It’s just that they started their post by saying that classes in Typescript should be avoided. A message "x should be avoided" is very different from "you don’t need x". Compare the statement "you don’t need redux", which has been incorporated into titles of numerous blog posts, with the statement "redux should be avoided".
[dead]
Re:Using TypeScript with React
by hombre_fatal on Thursday August 22, 2019 @07:57PM
(#20773485)
Why pick on a contrived example? You can fill in your own less-contrived state + methods, it's not really the point of their question.
As an example of the “OOP according to Java (and C++)” culture that is making JavaScript tedious to work in.
I want move past the “bad OOP” stuff shoved down my throat 30 years ago, into a style that is more FP oriented.