I ♥️ Hooks


I ♥️ Hooks. But they created a “2nd system” problem: There are 2 ways to do everything.

The function API is superior. 😀 But, most the React docs still use classes. 🤨

Every example in the docs needs a “class” and “function” version.

My hope: Deprecate classes in React 17...
Deprecation strategy:
1. Extract class support to a “react-class” npm package. (As they did with prop-types)
2. Publish codemod that adds an import to the top of each React class file
3. Update docs to use functions throughout
4. Create a “React with classes” section
Why deprecate classes?
1. One clear path for new dev = Less confusion
2. Freedom to add new features without supporting classes
3. Everyone benefits from using funcitons: Easy logic sharing via Hooks, less verbose, related code is co-located, easier open source support, etc.
Poll: I'm curious how others feel. Would you like to see class components extracted to a separate npm package in React 17?

View original on X