react-overridable
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
@@ -59,10 +57,7 @@ | ||
const overriddenComponents = React.useContext(OverridableContext); | ||
const child = children ? React__default.Children.only(children) : null; // throws an error if multiple children | ||
const child = children ? React__default.Children.only(children) : null; | ||
const childProps = child ? child.props : {}; | ||
const hasOverriddenComponent = (id in overriddenComponents); | ||
if (hasOverriddenComponent) { | ||
// If there's an override, we replace the component's content with | ||
// the override + props | ||
if (id in overriddenComponents) { | ||
// If there's an override, we replace the component's content with the override + props | ||
const Overridden = overriddenComponents[id]; | ||
@@ -145,6 +140,6 @@ return React__default.createElement(Overridden, _objectSpread(_objectSpread({}, childProps), restProps)); | ||
} | ||
const overrideStore = new OverriddenComponentRepository(); | ||
exports.OverridableContext = OverridableContext; | ||
exports.OverriddenComponentRepository = OverriddenComponentRepository; | ||
exports.default = Overridable; | ||
@@ -151,0 +146,0 @@ exports.overrideStore = overrideStore; |
@@ -52,10 +52,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
const overriddenComponents = useContext(OverridableContext); | ||
const child = children ? React.Children.only(children) : null; // throws an error if multiple children | ||
const child = children ? React.Children.only(children) : null; | ||
const childProps = child ? child.props : {}; | ||
const hasOverriddenComponent = (id in overriddenComponents); | ||
if (hasOverriddenComponent) { | ||
// If there's an override, we replace the component's content with | ||
// the override + props | ||
if (id in overriddenComponents) { | ||
// If there's an override, we replace the component's content with the override + props | ||
const Overridden = overriddenComponents[id]; | ||
@@ -138,7 +135,6 @@ return React.createElement(Overridden, _objectSpread(_objectSpread({}, childProps), restProps)); | ||
} | ||
const overrideStore = new OverriddenComponentRepository(); | ||
export default Overridable; | ||
export { OverridableContext, overrideStore, parametrize }; | ||
export { OverridableContext, OverriddenComponentRepository, overrideStore, parametrize }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-overridable", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Makes React components overridable.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8
33403
236