Skip to content

Enable functional composition for Higher-Order-Components #279

@roryabraham

Description

@roryabraham

Problem

We currently have no easy mechanism for functional composition. Therefore, it becomes harder to keep track when multiple HOC are used to wrap a component. This is going to be pretty common (using withRouter and withIon together, for example).

TL;DR:
Change this 🤢:

export default hoc1(config1, hoc2(config2, hoc3(config3)))(MyComponent);

To this 😇:

export default compose(
    hoc1(config1),
    hoc2(config2),
    hoc3(config3)
)(MyComponent)

Solution

Create a simple utility compose, enabling functional composition.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions