Skip to main content
InterviewHubPRO
Section Overview
Q216

Question 216 of 407

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

53%
React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

Is Hooks cover all use cases for classes?

mid LevelCode ExampleHooksFormsPerformance

Hooks doesn't cover all use cases of classes but there is a plan to add them soon. Currently there are no Hook equivalents to the uncommon getSnapshotBeforeUpdate and componentDidCatch lifecycles yet.

Practical Code Example

jsx
// Hooks cover 99% of use cases.
// Only two rare class lifecycles currently lack direct Hook equivalents:
// 1. componentDidCatch / getDerivedStateFromError (Error Boundaries)
// 2. getSnapshotBeforeUpdate