You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
InternshipProject/node_modules/rc-util/es/Children/toArray.js

20 lines
609 B

import React from 'react';
import { isFragment } from 'react-is';
export default function toArray(children) {
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var ret = [];
React.Children.forEach(children, function (child) {
if ((child === undefined || child === null) && !option.keepEmpty) {
return;
}
if (Array.isArray(child)) {
ret = ret.concat(toArray(child));
} else if (isFragment(child) && child.props) {
ret = ret.concat(toArray(child.props.children, option));
} else {
ret.push(child);
}
});
return ret;
}