Higher Order Component (HOC) is useful when you want to inject additional behaviours to the existing Component
. You can use HOC to inject:
- React Lifecycle (eg. execute code in
componentWillMount
) - State (eg. react-redux’s connect)
- Component (Parent Component, Child Component, Sibling Component)
- Style