3 ms·
Concise and simple functional components are often desirable. But class components and OOP allow you to make components that are complex yet generic and reusabl
by wishawa 5y ago
Concise and simple functional components are often desirable. But class components and OOP allow you to make components that are complex yet generic and reusable.
Example from real experience: I had an `InfinityScroller` functional component. The `loadMoreItems` prop signature was a function with ten arguments because different usages require different state data when deciding what to load.
I converted the component to class based. `loadMoreItems` became an abstract method. No more overly complicated type signature because I can just access and update `this.state`.