|
|
|
|
|
by acemarke
2377 days ago
|
|
Would it be _possible_ to implement hooks as part of classes? Sure, it's just software, code can implement basically anything. But, the React team deliberately opted to only implement hooks for function components for a few reasons: - Function components didn't have capability parity with class components in terms of having state and side effects - Class components already had the ability to do this kind of functionality overall - Long-term, function components are easier for React to deal with for things like hot reloading and the upcoming Concurrent Mode. By dangling a carrot to convince folks to move to function components + hooks, it becomes easier to implement that functionality for the React team. |
|