News for hackers. Stuff that matters.
Re:Rebuilding our tech stack for the new facebook.com by s-km on Friday May 08, 2020 @01:39PM (#23117375)
React components aren't a 1:1 mapping to the DOM, so you could in theory have 50 HoCs wrapping a single component and it still only output one div or whatever.

Also, HoCs have somewhat fallen out of favour over time, with hooks and the child as a function/render prop style becoming more popular. I think the only HoC I consistently use these days is `connect` from `react-redux`.

Re:Rebuilding our tech stack for the new facebook.com by lukevp on Friday May 08, 2020 @02:16PM (#23117767)
You can use hooks with redux now, so what’s the purpose of using connect instead of useDispatch or useSelector?
Re:Rebuilding our tech stack for the new facebook.com by Octoth0rpe on Friday May 08, 2020 @02:37PM (#23117967)
Two big reasons: Values passed via connect can be validated by proptypes, and by using connect you can mount your component without redux. That may make sense for building shared components that may be used with redux in one part of your app, but without redux in another part. There are a lot of smaller reasons to prefer connect, but those are the big ones to me. FWIW I use both approaches depending on needs.