Introduction
What's Higher Order Component (HoC)?
HoC is a composite component that wraps a bunch of widgets, with pre-defined behavior which is self-management of UI states.
With HoC, you can:
- Select, copy, delete, drag and move it as a whole, just like a widget.
- Hide and unhide it.
- Edit it to customize the outlook.
- Use its pre-defined behavior to manage the UI state itself, e.g.
StateButton
automatically synchronize image & label update as the state changes, and just have to focus on your business logic.
You cannot:
- Resize HoC directly, unless you change its wrapped widgets.
- Add or remove wrapped widgets from HoC, or change their order.
- Change the behavior of HoC.
How to use Hoc?
- Expand widget bar, you'd see a section of HoC, as below:
- Drag and drop a HoC from the widget bar to the screen, and use it like a normal widget.