Skip to content

Commit

Permalink
fix(breadcrumbs): support string children (#1769)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin authored Jan 6, 2022
1 parent 136db5b commit ebd7e7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ const Breadcrumbs = WithRef<HTMLElement, BreadcrumbsProps>(
const prefixCls = usePrefixCls('breadcrumbs');
const classes = classNames([className, prefixCls]);

const breadcrumbsItems = React.Children.toArray(children)
.filter((child) => React.isValidElement(child))
.map((child, index) => (
// eslint-disable-next-line react/no-array-index-key
<li className={`${prefixCls}__li`} key={`${prefixCls}-li-${index}`}>
{child}
</li>
));
const breadcrumbsItems = React.Children.toArray(children).map((child, index) => (
// eslint-disable-next-line react/no-array-index-key
<li className={`${prefixCls}__li`} key={`${prefixCls}-li-${index}`}>
{child}
</li>
));

return (
<nav ref={ref} className={classes} aria-label="breadcrumbs" data-testid="breadcrumbs" {...otherProps}>
Expand Down
4 changes: 1 addition & 3 deletions src/breadcrumbs/demos/Breadcrumbs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ const CustomSeparatorTemplate: Story<BreadcrumbsProps> = (args) => (
<Breadcrumbs separator={<RightDoubleOutlined size="14px" />} {...args}>
<Link href="/">主页</Link>
<Link href="https://www.growingio.com">二级导航</Link>
<Link aria-current="page" href="/?path=/story/upgraded-breadcrumb--default">
当前页面
</Link>
当前页面
</Breadcrumbs>
</>
);
Expand Down

1 comment on commit ebd7e7b

@vercel
Copy link

@vercel vercel bot commented on ebd7e7b Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.