UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

22 lines (20 loc) 729 B
"use strict"; import { Children, Fragment, isValidElement } from 'react'; import { logger } from './logs'; export const processChildren = children => Children.toArray(children).reduce((acc, child, index) => { if (! /*#__PURE__*/isValidElement(child)) { return acc; } // Handle React Fragments by recursively processing their children if (child.type === Fragment) { const fragmentChildren = processChildren(child.props.children); return [...acc, ...fragmentChildren]; } const key = child.key; if (!key) { logger.warn(`Child at index ${index} is missing a key prop. Using index as fallback.`); } acc.push([key || String(index), child]); return acc; }, []); //# sourceMappingURL=children.js.map