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.
15 lines
460 B
15 lines
460 B
2 years ago
|
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;
|