Skip to content

Commit

Permalink
fix(Breadcrumbs): Resolve strict null errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jpveooys committed Feb 8, 2022
1 parent d450510 commit bef0bd2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,8 @@ describe('Breadcrumbs', () => {
expect(wrapper.queryByText('Home')).toHaveAttribute('href', '#home')
})
})

it('does not throw an error if there are no children', () => {
expect(() => render(<Breadcrumbs />)).not.toThrowError()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Breadcrumbs: React.FC<Nav<BreadcrumbsItemProps>> = ({
...rest
}) => {
const mapped = React.Children.map(
children,
children ?? [],
(child: React.ReactElement<BreadcrumbsItemProps>, index: number) => {
warnIfOverwriting(child.props, 'isFirst', BreadcrumbsItem.name)
warnIfOverwriting(child.props, 'isLast', BreadcrumbsItem.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getText(

export const BreadcrumbsItem: React.FC<BreadcrumbsItemProps> = ({
isFirst,
isLast,
isLast = false,
link,
href,
children,
Expand Down

0 comments on commit bef0bd2

Please sign in to comment.