Hacker News new | past | comments | ask | show | jobs | submit login

Class components are deprecated. They only appear in the legacy section of the reference.

https://react.dev/reference/react/legacy




Minor correction -- It seems like the page you link to has two sections: Legacy APIs and Deprecated APIs. Class components are not deprecated; instead, they are in the legacy section. The only thing that is listed as deprecated in the page you link to is "createFactory -- lets you create a function that produces React elements of a certain type."


Oh also certain concepts and strategies are only written about in the legacy documentation. Good luck new devs!


Reminds me of a React V11 codebase at work. It is bad enough that I always include it as a heads up during our scoping, as in: "double your estimates because the version of React is so old"


happens to lots of stuff and is not react specific


Care to source/link them? You obviously think they're important so you should do some good and share!


New docs don't tell you how to get a minimal start anymore. You MUST fully commit to a create-react-app flow or similar, or they vaguely point you in the direction of Babel without explicit direction.

The formal way of using React and JSX without a full SPA framework is only listed here: https://legacy.reactjs.org/docs/add-react-to-a-website.html


Ah, I guess you're referring to how they're pushing frameworks over bundlers?

> If you want to build a new app or a new website fully with React, we recommend picking one of the React-powered frameworks popular in the community. Frameworks provide features that most apps and sites eventually need, including routing, data fetching, and generating HTML.

> Grab react and react-dom from npm, set up your custom build process with a bundler like Vite or Parcel, and add other tools as you need them for routing, static generation or server-side rendering, and more.

https://react.dev/learn/start-a-new-react-project#can-i-use-...


Getting started with parcel is pretty damned straight forward.

https://parceljs.org/recipes/react/


> These APIs are exported from the react package

You can still write React the old way.


Sure. But search anything about React, and you'll see examples in hooks.

I don't even understand the reason why class-based is "legacy". Why are hooks inherently better? Code-reuse is a factoring concern, not a paradigm concern. And component-life-cycle bugs are now replaced with nearly impossible to understand callback stacktraces.


That doesn't mean classes are deprecated, it means people prefer hooks, and I understand why, as someone that codes in both.

It's like saying "All Javascript things I search are only in ES2020." It doesn't mean javascript is deprecating features.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: