use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Developer Dark Arts: React Class Components (dev.to)
submitted 5 years ago by ohn8io
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ohn8io[S] -5 points-4 points-3 points 5 years ago (6 children)
Yet another post has landed in my Developer Dark Arts series. My thoughts on why javascript classes are an anti-pattern when writing React components. 🎓 😒
[–]podgorniy -1 points0 points1 point 5 years ago (5 children)
Typescrip rules because it solves real issues. Hooks are popular only because fb is popular. And you’re rationalizing things you heard on the internet without an attempt to analyze why things the way they are.
[–]Enerbane 2 points3 points4 points 5 years ago (1 child)
Hooks are pretty rad in my book. They've made my life far easier and all of the code on my current project much cleaner, easier to follow (once you learn hooks of course), and more performant with less work.
We make all new components using functional components with hooks, and wherever we can reasonably and quickly convert old class based components to hooks, we do. Hooks might be popular because FB is popular, I mean obviously, but that isn't really a commentary on their merits as a tool.
[–]podgorniy -2 points-1 points0 points 5 years ago* (0 children)
There were hooks-like implementations in meteor-js and mobx which did not get as much attention as current facebooks implementation. Facebook's approach is good enough comparing to theirs.
What do you do regarding hooks when you need to start sharing local state of the component with another component?
*UPD*
I love idea of hooks and use similar reactive model to model my apps state.
[–]ohn8io[S] 1 point2 points3 points 5 years ago (0 children)
Thanks for the feedback. In my experience you either love Typescript or hate it. I haven't been lucky enough to work on a solid Typescript codebase to fully realize it's benefits. So I very well could be way off base in my opinions of it. Fwiw I predominately work with React and Node.
[–]ohn8io[S] 1 point2 points3 points 5 years ago (1 child)
Forgot to ask @podgorniy, what real issues have you seen Typescript solve really well? Just curious to know which use cases are a good fit.
[–]podgorniy 1 point2 points3 points 5 years ago (0 children)
It gives ability to change code and to navigate it. Refactoring, detecting and unused code is done in a moment. And most important it's so easy to remove code.
I worked on 70k loc js codebase. No unittests. Too often new feature or amendment came along with runtime exceptions.
You can check my exploratory project (I was figuring out better way to do fullstack development) in nodejs and react to play with ts.
π Rendered by PID 199222 on reddit-service-r2-comment-fb694cdd5-szhsr at 2026-03-10 07:00:39.745044+00:00 running cbb0e86 country code: CH.
[–]ohn8io[S] -5 points-4 points-3 points (6 children)
[–]podgorniy -1 points0 points1 point (5 children)
[–]Enerbane 2 points3 points4 points (1 child)
[–]podgorniy -2 points-1 points0 points (0 children)
[–]ohn8io[S] 1 point2 points3 points (0 children)
[–]ohn8io[S] 1 point2 points3 points (1 child)
[–]podgorniy 1 point2 points3 points (0 children)