The problem
Class components spread one feature over several lifecycle methods: a subscription started in componentDidMount, changed in componentDidUpdate and stopped in componentWillUnmount. Reusing stateful logic between components meant wrapping them in higher-order components or render props, and this had to be bound in every handler.
The idea
useState gives a function component a piece of state that survives between renders; useEffect runs code after a render and cleans it up. A custom hook is a function that calls hooks: here useTodos() owns the list and the ways to change it, and any component can use it.
React calls the component again on every state change and compares the new output with the old one. Values like the counter are simply computed during render.
What hurt next
Everything still ran in the browser: the page arrived empty, every component's JavaScript had to download, run and render before anything useful appeared, and server rendering hydrated the whole page even where nothing was interactive. Effects with dependency arrays and stale closures became a common source of bugs. Islands and React Server Components moved the non-interactive parts back to the server.
How close this is to the original
Runs React 19.3.0. Hooks code from 2019 looks the same: useState, useEffect and custom hooks have not changed. Only the entry is newer: createRoot (React 18) replaced ReactDOM.render, which React 19 removed.