How to use the cloneElement function from react
Find comprehensive JavaScript react.cloneElement code examples handpicked from public code repositorys.
GitHub: rccoder/amazeui-react

120 121 122 123 124 125 126 127 128 129
function() { _this.setDropdown(false); } ) : onClick; return React.cloneElement( child, assign({}, child.props, { key: `dropdownItem-${index}`, onClick: handleClick
22 23 24 25 26 27 28 29 30
} return child; }); } if(children.type === ParallaxImage) { return React.cloneElement(children, props); } return children; };
+ 3 other calls in file
GitHub: sapegin/react-group

16 17 18 19 20 21 22 23 24
var separatorIsElement = React.isValidElement(separator); var items = [children.shift()]; children.forEach(function(item, index) { if (separatorIsElement) { var key = 'separator-' + (item.key || index); separator = React.cloneElement(separator, { key: key }); } items.push(separator, item); });
GitHub: benjycui/bisheng

4 5 6 7 8 9 10 11 12 13
return { converters: [ [ function (node) { return typeof node === 'function'; }, function (node, index) { return React.cloneElement(node(), { key: index }); }, ], ], };
GitHub: amazeui/amazeui-react

48 49 50 51 52 53 54 55 56 57
</div> ); }, renderChildBar: function(child, index) { return React.cloneElement(child, { isChild: true, key: child.key ? child.key : index }); },
GitHub: onejgordon/flow-dashboard

127 128 129 130 131 132 133 134 135 136
{ this.render_nav_menu() } </Drawer> <div id="container" className="container"> <div className="app-content"> { React.cloneElement(this.props.children, { user: user, signing_in: this.state.signing_in }) } </div> </div> <ReactTooltip place="top" effect="solid" />
158 159 160 161 162 163 164 165 166 167
renderTabBar(props) { if (this.props.renderTabBar === false) { return null; } else if (this.props.renderTabBar) { return React.cloneElement(this.props.renderTabBar(props), props); } else { return <DefaultTabBar {...props} />; } },
GitHub: Videri/material-ui

111 112 113 114 115 116 117 118 119
let children = [checkboxColumn]; React.Children.forEach(child.props.children, (child) => { children.push(child); }); return React.cloneElement(child, {...props, ...handlers}, children); } }); },
react.default is the most popular function in react (505 examples)