UNPKG

pure-styled-components

Version:

Styled Component design system based on Pure CSS for React/Preact

25 lines (21 loc) 849 B
import React from "react"; /** * Loops through children and adds provided props to specified component * * @param {React.Children} children - React Component's children * @param {React.Component} component - Component to search for and apply props to * @param {object} propsToAdd - Props to apply to component * @returns {React.Children} */ var addPropsToComponent = function addPropsToComponent(children, component, propsToAdd) { var type = [component.displayName] || [component.name]; return React.Children.map(children, function (child) { var childType = child && child.type && (child.type.displayName || child.type.name); if (type.includes(childType)) { return React.cloneElement(child, propsToAdd); } return child; }); }; export default addPropsToComponent; //# sourceMappingURL=addPropsToComponent.js.map