Skip to content

Commit

Permalink
[publish] fix breadcrumbs work with React.Fragment containers as a tr…
Browse files Browse the repository at this point in the history
…ansparent containers

reactjs/rfcs#61
  • Loading branch information
nightflash committed Sep 16, 2024
1 parent 64817e7 commit fc6507f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"postcss-loader": "^8.1.1",
"postcss-modules-values-replace": "^4.2.0",
"postcss-preset-env": "^10.0.3",
"react-keyed-flatten-children": "^3.0.2",
"react-movable": "^3.3.1",
"react-virtualized": "^9.22.5",
"react-waypoint": "^10.3.0",
Expand Down
5 changes: 3 additions & 2 deletions src/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import classNames from 'classnames';
import {Children, Fragment, ReactNode} from 'react';
import flattenChildren from 'react-keyed-flatten-children';
import {Fragment, ReactNode} from 'react';

import styles from './breadcrumbs.css';

Expand All @@ -9,7 +10,7 @@ export interface BreadcrumbsSeparatorAttrs {
}

export default function Breadcrumbs({separatorClassName, children}: BreadcrumbsSeparatorAttrs) {
return Children.toArray(children).map((child, index) => (
return flattenChildren(children).map((child, index) => (
// eslint-disable-next-line react/no-array-index-key
<Fragment key={index}>
{index > 0 && <span className={classNames(styles.separator, separatorClassName)}>{'/'}</span>}
Expand Down

0 comments on commit fc6507f

Please sign in to comment.