DEV Community

Discussion on: Introduction to Higher Order Components(HOCs)In React

Collapse
 
anpos231 profile image
anpos231 • Edited

I use HOC to separate logic from view.
Imagine you have component that allows users to select an item from a list.

I'd split it like this:
Functional component which is used to render the component.
Class component which holds logic/state for that component.

SelectLogic is a HOC for SelectView. Of course both components are replaceable, so you can switch Login/View depending on the needs.

Collapse
 
ogwurujohnson profile image
Johnson Ogwuru

That's okay too