Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Check if we find a string as a child before calling .toString()",
"packageName": "@fluentui-react-native/link",
"email": "[email protected]",
"dependentChangeType": "patch"
}
9 changes: 6 additions & 3 deletions packages/components/Link/src/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ export const Link = compose<LinkType>({
// Find the first child that's a string and save it to set as the link's
// accessibilityLabel if one isn't defined.
let linkA11yLabel = '';
linkA11yLabel = React.Children.toArray(children)
.find((child) => typeof child === 'string')
.toString();

const textChild = React.Children.toArray(children).find((child) => typeof child === 'string');

if (textChild != undefined) {
linkA11yLabel = textChild.toString();
}

return supportsA11yTextInText && supportsInteractionOnText && (inline || mergedProps.selectable) ? (
<Slots.content {...mergedProps}>{children}</Slots.content>
Expand Down
Loading