ant-design/components/timeline/useItems.ts
lijianan 0b6356d984
chore: rename file .tsx => .ts (#46759)
* chore: rename file .tsx => .ts

* fix: fix

* test: add test case
2024-01-03 08:45:11 +08:00

17 lines
470 B
TypeScript

import type * as React from 'react';
import toArray from 'rc-util/lib/Children/toArray';
import type { TimelineItemProps } from './TimelineItem';
function useItems(items?: TimelineItemProps[], children?: React.ReactNode): TimelineItemProps[] {
if (items && Array.isArray(items)) {
return items;
}
return toArray(children).map((ele: React.ReactElement<any>) => ({
children: ele?.props?.children ?? '',
...ele.props,
}));
}
export default useItems;