static getInitialProps({ renderPage }: (cb: Function) => void) { AppRegistry.registerComponent('Main', () => Main); // $FlowFixMe Wrong libdef. https://gist.github.com/paularmstrong/f60b40d16fc83e1e8e532d483336f9bb const { getStyleElement } = AppRegistry.getApplication('Main'); const page = renderPage(); const styles = [ // eslint-disable-next-line react/jsx-key <style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />, getStyleElement(), ]; return { ...page, styles: React.Children.toArray(styles) }; }
function loopTabList(tabList, cb) { React.Children.forEach(tabList, tab => { if (isTab(tab)) { cb(); } }); }
ReactChildren.forEach(props.children, function(child, index) { if (child == null) { return; } invariant( child.type.__TableColumnGroup__ || child.type.__TableColumn__, 'child type should be <FixedDataTableColumn /> or ' + '<FixedDataTableColumnGroup />' ); children.push(child); });
const Suffix = ({ children }) => { const suffix = React.Children.map(children, child => { if (React.isValidElement(child)) { return React.cloneElement(child, { size: 16, }); } return child; }); return <View style={styles.suffix}>{suffix}</View>; }
render() { const { children, ...extraProps } = this.props; const { activeIndex } = this.state; const props = { handleTabChange: this.handleTabChange, handleTabSequence: this.handleTabSequence, handleEdit: this.handleEdit, activeIndex, ...extraProps, }; return ( <div> {React.Children.map(children, child => { return React.cloneElement(child, props); })} </div> ); }
function deepLoop(children: React.ChildrenArray<any>, cb) { React.Children.forEach(children, child => { if (isTabList(child)) { if (child.props && child.props.children) { return loopTabList(child.props.children, cb); } else { throw new Error("You need to provide `Tab` children"); } } else if (child.props && child.props.children) { deepLoop(child.props.children, cb); } }); }
render() { const { children, activeIndex, customStyle } = this.props; if (!children || activeIndex === undefined) { return null; } let props = {}; if (customStyle && customStyle.Panel) { props = { ...props, CustomPanelStyle: customStyle.Panel }; } // to prevent the type of one children is object type const result = React.Children.toArray(children).map((child, index) => React.cloneElement(child, { key: index, active: index === activeIndex, index, ...props, }), ); return <div>{result}</div>; }
React.Children.forEach(children, (child) => { const props = proxies[child.type] = Object.assign({}, child.props) if (child.key != null) { props.key = child.key } if (child.ref != null) { props.ref = child.ref } })
React.Children.forEach(children, (child) => { const props = Object.assign({}, child.props) if (!proxies[child.type]) { proxies[child.type] = props } else if (!(proxies[child.type] instanceof Array)) { proxies[child.type] = [proxies[child.type], props] } else { proxies[child.type].push(props) } if (child.key != null) { props.key = child.key } if (child.ref != null) { props.ref = child.ref } })
/** * Helper method to execute a callback against all columns given the children * of a table. * @param {?object|array} children * Children of a table. * @param {function} callback * Function to excecute for each column. It is passed the column. */ function forEachColumn(children, callback) { React.Children.forEach(children, function(child) { if (child.type === FixedDataTableColumnGroup.type) { forEachColumn(child.props.children, callback); } else if (child.type === FixedDataTableColumn.type) { callback(child); } }); }
React.Children.forEach(children, function () { return ++childCount; });
React.Children.forEach(children, (child) => { const props = proxies[child.type] = Object.assign({}, child.props) if (child.key != null) { props.key = child.key } if (child.ref != null) { props.ref = child.ref } })
React.Children.forEach(children, (child) => { const props = proxies[child.type] = Object.assign({}, child.props) if (child.key != null) { props.key = child.key } if (child.ref != null) { props.ref = child.ref } })
React.Children.forEach(children, function () { return ++childCount; });
React.Children.forEach(children, (child) => { const props = Object.assign({}, child.props) if (!proxies[child.type]) { proxies[child.type] = props } else if (!(proxies[child.type] instanceof Array)) { proxies[child.type] = [proxies[child.type], props] } else { proxies[child.type].push(props) } if (child.key != null) { props.key = child.key } if (child.ref != null) { props.ref = child.ref } })