Skip to content
Created: August 26, 2025

A short conclusion for you first:

  • Now (React 16.8+) 👉 Almost all new projects: choose Hooks
  • Class is mainly "historical legacy + maintenance of old code"

1. From the official and ecological reality ​

1️⃣ The official attitude has been very clear ​

  • New features are only designed around Hooks

    • useState / useEffect / useTransition / useSyncExternalStore
    • Server Components、Concurrent Features
  • Class is not deprecated, but will not be enhanced

  • The core meaning of the original words of the React team:
  • Class is the compatibility layer, Hooks is the future

2️⃣ Ecological status quo ​

  • New library almost Only provides Hooks API

    • React Query
    • Zustand / Jotai / Redux Toolkit
    • Framer Motion
  • Tutorials, Examples, Best Practices: 99% Hooks

👉 Using Class will make you break away from the mainstream ecology

2. From the perspective of "coding experience" and "maintainability" ​

1️⃣ Same logic, compare ​

Class ​

js
class Counter extends React.Component {
  state = { count: 0 }

  componentDidMount() {
    document.title = this.state.count
  }

  componentDidUpdate() {
    document.title = this.state.count
  }

  render() {
    return (
      <button onClick={() => this.setState({ count: this.state.count + 1 })}>
        {this.state.count}
      </button>
    )
  }
}

Hooks ​

js
function Counter() {
  const [count, setCount] = useState(0)

  useEffect(() => {
    document.title = count
  }, [count])

  return (
    <button onClick={() => setCount(c => c + 1)}>
      {count}
    </button>
  )
}

👉 The advantage of Hooks is not just "short", but:

  • Logic aggregation by "function"
  • no longer scattered across componentDidMount / Update / WillUnmount
  • No this
  • No need to manually bind context

2️⃣ Logic reuse: Hooks wins ​

Class reuse method (history) ​

  • HOC (nested hell)
  • Render Props (JSX nesting doll)

Hooks ​

js
function useTitle(title) {
  useEffect(() => {
    document.title = title
  }, [title])
}

Custom Hook = "Function Abstraction" at the logical level

This is something Class can never do.

3. From the perspective of React’s internal principles ​

  • Fiber
  • renderWithHooks
  • Hooks Dispatcher
  • Why can't hooks be written in conditions?

👉 This is exactly the key point.

1️⃣ Hooks and Fiber are "natively bound" ​

  • Each Function Component corresponds to a Fiber

  • Hooks exist on the linked list of Fiber.memoizedState

  • renderWithHooks When rendering:

    • Set up Dispatcher (mount/update)
    • Sequential reading hooks

👉 Hooks are “first-class citizens” of React’s new architecture

2️⃣ Class is essentially “outer encapsulation” ​

  • this.state、this.setState
  • life cycle methods
  • All simulated on Fiber

It can be understood as:

  • Class = old API, running on new kernel
  • Hooks = use the new kernel directly

4. Are there any “better” scenes in Class? ​

Yes, but rarely 👇

✅Suitable for using Class ​

  1. Maintain old projects
  2. The code base is already in Class style and there are no plans to refactor it.
  3. Requires componentDidCatch (but now Hooks have alternatives)

❌ Situations when it is not suitable to reuse Class ​

  • new project
  • new components
  • Want to learn React principles/concurrency features
  • Want to follow the mainstream ecology

5. A conclusion from an engineer’s perspective ​

  • Class is "How to use React"
  • Hooks are "how to think about React"

If you are asking:

  • Interview 👉 Hooks
  • Actual Development 👉 Hooks
  • Deep into the source code / Fiber / Scheduler 👉 Required Hooks
  • Take over the old code 👉 Just understand Class, no need to write new ones