mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
15 lines
460 B
TypeScript
15 lines
460 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;
|