The compose utility is a factory version of Compose component.
import { compose, Counter, Toggle } from 'react-powerplug' // note lowercased (c)ompose
// the order matters
const ToggleCounter = compose(
<Counter initial={5} />, // accept a element
Toggle, // or just a component
)
<ToggleCounter>
{(counter, toggle) => {
// counter.inc, counter.dec, counter.count
// toggle.on, toggle.toggle, etc.
}}
</ToggleCounter>
Behind the scenes, that's what happens:
<Counter initial={5}>
{counter => (
<Toggle>
{toggle => (
/* ... */
)}
</Toggle>
)}
</Counter>