Skip to content

Commit

Permalink
use display name for styled custom element (#4403)
Browse files Browse the repository at this point in the history
* use display name for styled custom element

* changeset

* ensure Styled doesnt change displayName
  • Loading branch information
keithamus authored and lukasoppermann committed Apr 16, 2024
1 parent 302ad47 commit a8d751d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-drinks-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Improve display names for React components built from Custom Elements
19 changes: 12 additions & 7 deletions packages/react/src/utils/custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ export const createComponent = <I extends HTMLElement, E extends EventNames = {}
events: E | undefined = undefined,
) => {
const output = Object.assign(
styled(
create<I, E>({
tagName,
elementClass,
react: React,
events,
}),
Object.assign(
styled(
create<I, E>({
tagName,
elementClass,
react: React,
events,
}),
),
{
displayName: rename(tagName),
},
)(sx),
{
displayName: rename(tagName),
Expand Down

0 comments on commit a8d751d

Please sign in to comment.