@reactioncommerce/components-context
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -13,2 +13,6 @@ "use strict"; | ||
var _hoistNonReactStatics = require("hoist-non-react-statics"); | ||
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -18,2 +22,13 @@ | ||
/** | ||
* @see https://reactjs.org/docs/higher-order-components.html#convention-wrap-the-display-name-for-easy-debugging | ||
* @param {Object} HOC The higher-order component | ||
* @param {Object} WrappedComponent The wrapped component | ||
* @returns {undefined} | ||
*/ | ||
function wrapDisplayName(HOC, WrappedComponent) { | ||
var innerDisplayName = WrappedComponent.displayName || WrappedComponent.name || "Component"; | ||
HOC.displayName = "WithComponents(" + innerDisplayName + ")"; | ||
} | ||
var ComponentsContext = _react2.default.createContext(); | ||
@@ -37,3 +52,3 @@ | ||
return _react2.default.forwardRef(function (props, ref) { | ||
var WithComponents = _react2.default.forwardRef(function (props, ref) { | ||
return _react2.default.createElement( | ||
@@ -68,2 +83,10 @@ ComponentsContext.Consumer, | ||
}); | ||
// https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over | ||
(0, _hoistNonReactStatics2.default)(WithComponents, Component); | ||
// https://reactjs.org/docs/higher-order-components.html#convention-wrap-the-display-name-for-easy-debugging | ||
wrapDisplayName(WithComponents, Component); | ||
return WithComponents; | ||
} |
{ | ||
"name": "@reactioncommerce/components-context", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A system for injecting React components into other React components from a central components context", | ||
@@ -21,3 +21,5 @@ "main": "./dist/main.js", | ||
"homepage": "https://github.com/reactioncommerce/components-context#readme", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"hoist-non-react-statics": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
@@ -24,0 +26,0 @@ "@commitlint/cli": "7.0.0", |
# @reactioncommerce/components-context | ||
![npm (scoped)](https://img.shields.io/npm/v/@reactioncommerce/components-context.svg) | ||
[![CircleCI](https://circleci.com/gh/reactioncommerce/components-context.svg?style=svg)](https://circleci.com/gh/reactioncommerce/components-context) | ||
A system for injecting React components into other React components from a central components context. | ||
@@ -4,0 +7,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53025
69
117
2
+ Addedhoist-non-react-statics@3.3.2(transitive)