informed
Version:
A lightweight framework and utility for building powerful forms in React applications
40 lines (32 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var Context = require('../Context.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
// eslint-disable-next-line no-unused-vars
var Scope = function Scope(_ref) {
var scope = _ref.scope,
children = _ref.children;
// Name might be scoped
var parentScope = React.useContext(Context.ScopeContext);
var newScope;
// Example:
// parentScope = undefined
// scope = father
// ==> father
if (!parentScope) {
newScope = scope;
}
// Example:
// parentScope = father
// scope = bestFriend
// ==> father.bestFriend
else {
newScope = "".concat(parentScope, ".").concat(scope);
}
return /*#__PURE__*/React__default["default"].createElement(Context.ScopeContext.Provider, {
value: newScope
}, children);
};
exports.Scope = Scope;