react-native-sortables
Version:
Powerful Sortable Components for Flexible Content Reordering in React Native
22 lines (20 loc) • 731 B
JavaScript
;
import { Children, Fragment, isValidElement } from 'react';
import { logger } from './logs';
export const validateChildren = 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 = validateChildren(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