Giant Components and Related Logic Scattered
What you'll learn: How class component lifecycle methods forced developers to split related logic across multiple methods, creating bloated, hard-to-maintain components.
The Lifecycle Fragmentation Problem
In class components, lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount organize code by when it runs, not by what it does. This creates a painful split: related logic that conceptually belongs together must be scattered across different lifecycle methods.
Imagine organizing a library where all opening tasks go in one room, all closing tasks in another, and all "during the day" tasks in a third—regardless of topic. Finding everything about "inventory management" now requires visiting three different rooms. That's exactly what happened with class components.
The Practical Pain
A single component often needs to manage multiple unrelated concerns:
- Fetching user data
- Setting up WebSocket connections
- Subscribing to browser events
- Starting analytics timers
Each concern requires setup (in componentDidMount), updates (in componentDidUpdate with conditionals), and cleanup (in componentWillUnmount). Your WebSocket logic is now split across three methods, mixed with completely unrelated data fetching logic in each method.
The result? Giant components where:
- Related logic is fragmented across lifecycle methods
- Unrelated logic is mashed together in the same method
- Reading or debugging one feature requires jumping between methods
- Extracting reusable logic becomes nearly impossible
Key Takeaway: Class lifecycle methods organized code by timing rather than purpose, forcing related logic to scatter across componentDidMount, componentDidUpdate, and componentWillUnmount while cramming unrelated concerns together—making components large, fragile, and hard to understand.