Skip to content

Commit

Permalink
Add displayNames to Global and ClassNames components (#2132)
Browse files Browse the repository at this point in the history
* add displayName for Global component

* add displayName to ClassNames

* add displayName to component returned by withEmotionCache

* add changeset

* add optional displayName to withEmotionCache func

* fix func type

* revert changes in withEmotionCache

* Update .changeset/kind-dots-confess.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
dcastil and Andarist committed Dec 5, 2020
1 parent 0d47e57 commit 3f8bf70
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-dots-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/react': patch
---

`displayName`s have been added to `Global` and `ClassNames` components so React Developer Tools should display those better now.
4 changes: 4 additions & 0 deletions packages/react/src/class-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ export const ClassNames: React.AbstractComponent<
}
return ele
})

if (process.env.NODE_ENV !== 'production') {
ClassNames.displayName = 'EmotionClassNames'
}
4 changes: 4 additions & 0 deletions packages/react/src/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ export let Global: React.AbstractComponent<

return null
})

if (process.env.NODE_ENV !== 'production') {
Global.displayName = 'EmotionGlobal'
}

0 comments on commit 3f8bf70

Please sign in to comment.