Skip to content

Commit

Permalink
fix(react): don't add mocked-styled classnames outside test env (#1252
Browse files Browse the repository at this point in the history
)

Fixes #1251
  • Loading branch information
leiit committed Jul 3, 2023
1 parent 00b43a6 commit 1085992
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-clouds-explode.md
@@ -0,0 +1,5 @@
---
'@linaria/react': patch
---

Don't add `mocked-styled` classnames outside test env
12 changes: 8 additions & 4 deletions packages/react/src/styled.ts
Expand Up @@ -134,10 +134,14 @@ function styled(
component: 'The target component should have a className prop'
): never;
function styled(tag: any): any {
// eslint-disable-next-line no-plusplus
let mockedClass = `mocked-styled-${idx++}`;
if (tag?.__linaria?.className) {
mockedClass += ` ${tag.__linaria.className}`;
let mockedClass = '';

if (process.env.NODE_ENV === 'test') {
// eslint-disable-next-line no-plusplus
mockedClass += `mocked-styled-${idx++}`;
if (tag?.__linaria?.className) {
mockedClass += ` ${tag.__linaria.className}`;
}
}

return (options: Options) => {
Expand Down

0 comments on commit 1085992

Please sign in to comment.