@shopify/react-compose
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -13,13 +13,5 @@ "use strict"; | ||
return function wrapComponent(OriginalComponent) { | ||
var result; | ||
if (wrappingFunctions.length === 0) { | ||
result = OriginalComponent; | ||
} | ||
else { | ||
result = wrappingFunctions.reduce(function (wrappingFunctionA, wrappingFunctionB) { | ||
return function (WrappingComponent) { | ||
return wrappingFunctionA(wrappingFunctionB(WrappingComponent)); | ||
}; | ||
})(OriginalComponent); | ||
} | ||
var result = wrappingFunctions.reduceRight(function (component, wrappingFunction) { | ||
return wrappingFunction(component); | ||
}, OriginalComponent); | ||
return hoist_non_react_statics_1.default(result, OriginalComponent); | ||
@@ -26,0 +18,0 @@ }; |
{ | ||
"name": "@shopify/react-compose", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"license": "MIT", | ||
@@ -33,3 +33,2 @@ "description": "Cleanly compose multiple component enhancers together with minimal fuss", | ||
"@types/enzyme": "^3.1.10", | ||
"enzyme": "^3.3.0", | ||
"typescript": "~3.0.1" | ||
@@ -36,0 +35,0 @@ }, |
@@ -17,15 +17,8 @@ import * as React from 'react'; | ||
): ReactComponent<Props> & C { | ||
let result: ReactComponent<ComposedProps>; | ||
const result: ReactComponent<ComposedProps> = wrappingFunctions.reduceRight( | ||
(component: ReactComponent<any>, wrappingFunction: WrappingFunction) => | ||
wrappingFunction(component), | ||
OriginalComponent, | ||
); | ||
if (wrappingFunctions.length === 0) { | ||
result = OriginalComponent; | ||
} else { | ||
result = wrappingFunctions.reduce( | ||
(wrappingFunctionA, wrappingFunctionB) => { | ||
return (WrappingComponent: ReactComponent<any>) => | ||
wrappingFunctionA(wrappingFunctionB(WrappingComponent)); | ||
}, | ||
)(OriginalComponent); | ||
} | ||
return hoistStatics( | ||
@@ -32,0 +25,0 @@ result as ComponentClass, |
2
11206
180