top | item 43422616

(no title)

crab_galaxy | 11 months ago

Class components and HOCs aren’t deprecated though.

discuss

order

only-one1701|11 months ago

They're very much not "best practices", and will be deprecated soon (if they're not already).

hajile|11 months ago

You still can't add features like error boundaries in React without class-based components somewhere in your app. Even if they added these features to functional components today, it would be years before they'd consider them safe to remove.

HOC still exist and builtin features like `React.memo(MyComponent)` along with the like of more functional styles means they aren't ever going away.

madeofpalk|11 months ago

But they're not deprecated. Where's the forced churn?

Every place that I've been at has made the gradual shift to migrate stuff away from class components as new stuff gets built or refactored. Seems like a pretty common development habit.

jbreckmckye|11 months ago

I'm not aware of any indication that class components will be deprecated.

jdauriemma|11 months ago

That's not true (the deprecation part, anyway) and I know of at least one React team member who has spoken publicly to that fact.

only-one1701|11 months ago

Mea culpa: they’re not being deprecated. But the existence of custom hooks removes the bulk of (if not all of) their utility, and make it much easier to reason about code and make your code well-typed.