Skip to content

Commit

Permalink
Merge 74aa001 into 434f542
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolinisoup authored May 17, 2023
2 parents 434f542 + 74aa001 commit 706b701
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-shoes-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Octicons (previously known StyledOcticons) to use React.forwardRef()
7 changes: 4 additions & 3 deletions src/Octicon/Octicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {ComponentProps} from '../utils/types'

type StyledOcticonProps = {icon: React.ElementType; color?: string} & IconProps

function Icon({icon: IconComponent, ...rest}: StyledOcticonProps) {
return <IconComponent {...rest} />
}
const Icon = React.forwardRef((props: StyledOcticonProps, ref: React.Ref<SVGSVGElement>) => {
const {icon: IconComponent, ...rest} = props
return <IconComponent {...rest} ref={ref} />
})

const Octicon = styled(Icon)<SxProp>`
${({color, sx: sxProp}) => sx({sx: {color, ...sxProp}})}
Expand Down

0 comments on commit 706b701

Please sign in to comment.