UNPKG

@shopify/react-compose

Version:

Cleanly compose multiple component enhancers together with minimal fuss

13 lines (12 loc) 514 B
import hoistStatics from 'hoist-non-react-statics'; export default function compose() { for (var _len = arguments.length, wrappingFunctions = new Array(_len), _key = 0; _key < _len; _key++) { wrappingFunctions[_key] = arguments[_key]; } return function wrapComponent(OriginalComponent) { var result = wrappingFunctions.reduceRight(function (component, wrappingFunction) { return wrappingFunction(component); }, OriginalComponent); return hoistStatics(result, OriginalComponent); }; }