Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Drop hoist-non-react-statics
  • Loading branch information
Andarist committed Dec 10, 2024
commit 3225ece5f89133d5fe9f086c1f32f66a278dccc2
5 changes: 5 additions & 0 deletions .changeset/tame-pets-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/react': major
---

`withTheme` will no longer automatically hoist non-React statics onto the created component
14 changes: 0 additions & 14 deletions packages/react/__tests__/with-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ test('withTheme works', () => {
).toMatchSnapshot()
})

test(`withTheme(Comp) hoists non-react static class properties`, () => {
class ExampleComponent extends React.Component {
static displayName = 'foo'
static someSpecialStatic = 'bar'
}

const ComponentWithTheme = withTheme(ExampleComponent)

expect(ComponentWithTheme.displayName).toBe('WithTheme(foo)')
expect(ComponentWithTheme.someSpecialStatic).toBe(
ExampleComponent.someSpecialStatic
)
})

test.skip('should forward the ref', () => {
function SomeComponent(props) {
return <div ref={props.ref}>{props.theme.color}</div>
Expand Down
61 changes: 2 additions & 59 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,60 +113,6 @@
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
},
"./_isolated-hnrs": {
"types": {
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
},
"development": {
"edge-light": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"worker": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"workerd": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"browser": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.development.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.development.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.development.cjs.js"
},
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.cjs.js"
},
"edge-light": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"worker": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"workerd": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"browser": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.cjs.js"
},
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
},
"./jsx-dev-runtime": {
"types": {
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
Expand Down Expand Up @@ -266,8 +212,7 @@
"@emotion/serialize": "^1.3.3",
"@emotion/use-insertion-effect-with-fallbacks": "^1.2.0",
"@emotion/utils": "^1.4.2",
"@emotion/weak-memoize": "^0.4.0",
"hoist-non-react-statics": "^3.3.1"
"@emotion/weak-memoize": "^0.4.0"
},
"peerDependencies": {
"react": ">=16.8.0"
Expand All @@ -283,7 +228,6 @@
"@emotion/css-prettifier": "1.2.0",
"@emotion/server": "11.11.0",
"@emotion/styled": "11.14.0",
"@types/hoist-non-react-statics": "^3.3.5",
"html-tag-names": "^1.1.2",
"react": "16.14.0",
"svg-tag-names": "^1.1.1",
Expand All @@ -298,8 +242,7 @@
"entrypoints": [
"./index.ts",
"./jsx-runtime.ts",
"./jsx-dev-runtime.ts",
"./_isolated-hnrs.ts"
"./jsx-dev-runtime.ts"
],
"umdName": "emotionReact",
"exports": {
Expand Down
15 changes: 0 additions & 15 deletions packages/react/src/_isolated-hnrs.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/react/src/theming.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react'
import weakMemoize from '@emotion/weak-memoize'
import isDevelopment from '#is-development'
import hoistNonReactStatics from './_isolated-hnrs'
import { DistributiveOmit } from './types'

// tslint:disable-next-line: no-empty-interface
Expand Down Expand Up @@ -98,5 +97,5 @@ export function withTheme<

WithTheme.displayName = `WithTheme(${componentName})`

return hoistNonReactStatics(WithTheme, Component)
return WithTheme
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbf maybe we should just remove withTheme altogether...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♀️ it takes like no code, is trivially tree shakable so I'd kinda err on the side of keeping it to just not break stuff but eh, I don't have strong feelings about it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that’s also why i have decided to keep it in the end

}
2 changes: 2 additions & 0 deletions packages/styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"devDependencies": {
"@definitelytyped/dtslint": "0.0.112",
"@emotion/react": "11.14.0",
"@types/hoist-non-react-statics": "^3.3.5",
"hoist-non-react-statics": "^3.3.1",
"react": "16.14.0",
"typescript": "^5.4.5"
},
Expand Down
Loading