@razorpay/blade
Version:
The Design System that powers Razorpay
30 lines (27 loc) • 1.11 kB
JavaScript
import React__default from 'react';
import '../isValidAllowedChildren/index.js';
import '../logger/index.js';
import { getComponentId } from '../isValidAllowedChildren/isValidAllowedChildren.js';
import { throwBladeError } from '../logger/logger.js';
/**
* Verify if the passed childrens are only of allowedComponents list
*/
var useVerifyAllowedChildren = function useVerifyAllowedChildren(props) {
var children = props.children,
componentName = props.componentName,
allowedComponents = props.allowedComponents;
if (false) {
React__default.Children.forEach(children, function (child) {
if (! /*#__PURE__*/React__default.isValidElement(child)) return;
var isValidChild = child && allowedComponents.includes(getComponentId(child));
if (!isValidChild) {
throwBladeError({
message: "Only `".concat(allowedComponents.join(', '), "` components are accepted in `").concat(componentName, "` children"),
moduleName: componentName
});
}
});
}
};
export { useVerifyAllowedChildren };
//# sourceMappingURL=useVerifyAllowedChildren.js.map