Incompose
Incompose is a Inferno.js clone of the famous recompose lib for React.
Installation
npm install incompose
Incompose / Inferno version map
Incompose works with specific version of inferno. Please make sure you use the correct version.
Inferno verion | Incompose version |
---|---|
v7.x |
>= v.5.0.0 |
v6.x |
>= v.4.0.0 |
v5.x |
>= v.3.0.0 |
v4.x |
v.2.0.0 |
< v4.0 |
< v.2 |
Support
Following HoCs are available. If you miss any helper/HoC please send me a note on twitter @roman_zanettin or create an issue / open a PR. Thanks.
Usage
Please find the API and example code in the docs folder.
Import
Incompose provides named and default imports:
;;
Example
; ; const inc = { props;}; const dec = { props;}; const Counter = <div> <h1>count : propscount</h1> <button onClick=>-</button> <button onClick=>+</button> </div>; /** * with state creates 2 new props on the component props * props.count - contains the value (1 is set as default value) * props.setCount - contains the setter function */const withCounterState = ; /** * should update prevents the component of re-render (shouldUpdate lifecycle hook) * you can compare current and next props and decide whether the component * should update or not. In this example, the counter just updates if * props.count is even. */const withUpdatePolicy = ; /** * with compose all the extended functions are composed BEFORE Counter * gets rendered. Please not that order matters. */ withCounterState withUpdatePolicyCounter;
Thanks
Special thanks to all the contributors and Andrew Clark (@acdlite) for creating this amazing lib for React!
Changelog
Changelog is available here.