Skip to content

Commit

Permalink
Choose fragments over arrays and keys
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed Nov 4, 2024
1 parent ae2da82 commit 1a0106d
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/react/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,28 @@ export const Button = forwardRef(
case !icon:
return children
case iconBefore:
return [<Icon key={1} svg={icon} size="level-5" />, children]
case iconOnly:
return [
<Icon key={1} svg={icon} size="level-5" square={true} />,
<span className="ams-visually-hidden" key={2}>
return (
<>
<Icon svg={icon} size="level-5" />
{children}
</span>,
]
</>
)
case iconOnly:
return (
<>
<Icon svg={icon} size="level-5" square={true} />
<span className="ams-visually-hidden" key={2}>
{children}
</span>
</>
)
default:
return [children, <Icon key={1} svg={icon} size="level-5" />]
return (
<>
{children}
<Icon svg={icon} size="level-5" />
</>
)
}
}

Expand Down

0 comments on commit 1a0106d

Please sign in to comment.