Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am disappointed with the React team’s decision to push functional components and hooks as the standard way of working with React. Not sure if the reason is to make React more approachable to newcomers or not, but in my experience leveraging the power of the component lifecycle through class components and decorators is the most fool-proof way to build and maintain large applications. Particularly leveraging shouldCompomentUpdate for performance and componentDidMount/componentsWillUnmount for registering and disposing of component dependencies is very easy to reason about and scale.


The reason they introduced hooks was exactly that component lifecycle and decorators/higher order components were found not to scale well in larger codebases (as experienced by the people using React at Facebook).

The useEffect pretty much provides a direct replacement for componentDidMount/componentWillUnmount.

I'm still on the fence, but so far it seems to me that using hooks makes my intent clearer than using the various lifecycle methods.


Can you provide links to articles where react devs detail the scaling issues?

I've found HOCs easy to combine and reason about if I name them carefully, and am still using them on personal projects. When people complain about HOCs not scaling well, are they primarily complaining about name collisions, or performance issues due to deeply nested components/lots of render calls?


It's primarily about naming collisions and indirection.

I covered some of the tradeoffs in this post and talk:

https://blog.isquaredsoftware.com/2019/07/blogged-answers-th...

https://blog.isquaredsoftware.com/2019/09/presentation-hooks...


It's a different way to do things. You can still use Class based components to your heart's content.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: