@shopify/react-compose
Version:
Cleanly compose multiple component enhancers together with minimal fuss
17 lines (13 loc) • 599 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = compose;
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function compose(...wrappingFunctions) {
return function wrapComponent(OriginalComponent) {
const result = wrappingFunctions.reduceRight((component, wrappingFunction) => wrappingFunction(component), OriginalComponent);
return (0, _hoistNonReactStatics.default)(result, OriginalComponent);
};
}