How to use the Children function from react
Find comprehensive JavaScript react.Children code examples handpicked from public code repositorys.
GitHub: rccoder/amazeui-react
109 110 111 112 113 114 115 116 117 118
}, renderChildren: function() { var _this = this; return React.Children.map(this.props.children, (child, index) => { if (React.isValidElement(child)) { var closeOnClick = child.props.closeOnClick; var onClick = child.props.onClick; var handleClick = closeOnClick ? createChainedFunction(
235
0
2
GitHub: esxjs/esx
0 1 2 3 4 5 6 7 8 9
'use strict' const esx = require('../..')() const React = require('react') const Cmp2 = ({ children }) => { const cloned = React.Children.map(children, (el) => React.cloneElement(el, { new: 'prop' }, 'hi')) return esx`<p>${cloned}</p>` } esx.register({ Cmp2 }) const Cmp1 = (props) => {
14
647
10
GitHub: sapegin/react-group
4 5 6 7 8 9 10 11 12
* React component to render collection of items separated by space or other separator. * * @visibleName React Group */ function Group(props) { var children = React.Children.toArray(props.children).filter(Boolean); if (children.length === 1) { return children; }
3
48
3
639 640 641 642 643 644 645 646 647 648 649
var StyledButtonMenu = styled__default['default'].div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n background-color: ", ";\n border-radius: 16px;\n display: inline-flex;\n\n & > button + button,\n & > a + a {\n margin-left: 2px; // To avoid focus shadow overlap\n }\n"], ["\n background-color: ", ";\n border-radius: 16px;\n display: inline-flex;\n\n & > button + button,\n & > a + a {\n margin-left: 2px; // To avoid focus shadow overlap\n }\n"])), getBackgroundColor); var templateObject_1$7; var ButtonMenu = function (_a) { var _b = _a.activeIndex, activeIndex = _b === void 0 ? 0 : _b, _c = _a.size, size = _c === void 0 ? sizes.MD : _c, _d = _a.variant, variant = _d === void 0 ? variants.PRIMARY : _d, onClick = _a.onClick, children = _a.children; return (React__default['default'].createElement(StyledButtonMenu, { variant: variant }, React.Children.map(children, function (child, index) { return React.cloneElement(child, { isActive: activeIndex === index, onClick: onClick ? function () { return onClick(index); } : undefined, size: size,
1
1
0
+ 3 other calls in file
2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
function flattenOptionChildren(children) { var content = ''; // Flatten children and warn if they aren't strings or numbers; // invalid types are ignored. React.Children.forEach(children, function (child) { if (child == null) { return; }
0
0
1
355 356 357 358 359 360 361 362 363 364
this.goToPage(this.state.currentPage); }); }, _children(children = this.props.children) { return React.Children.map(children, (child) => child); }, render() { let overlayTabs = (this.props.tabBarPosition === 'overlayTop' || this.props.tabBarPosition === 'overlayBottom');
0
0
0
GitHub: Videri/material-ui
107 108 109 110 111 112 113 114 115 116
if (rowNumber === numChildren) { props.displayBorder = false; } let children = [checkboxColumn]; React.Children.forEach(child.props.children, (child) => { children.push(child); }); return React.cloneElement(child, {...props, ...handlers}, children);
0
0
17
+ 7 other calls in file
react.default is the most popular function in react (505 examples)