Skip to content

Commit

Permalink
Drop hoist-non-react-statics (#3290)
Browse files Browse the repository at this point in the history
* Drop `hoist-non-react-statics`

* update lockfile
  • Loading branch information
Andarist authored Dec 11, 2024
1 parent 61fcc80 commit 6158389
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 92 deletions.
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
}
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
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2899,8 +2899,6 @@ __metadata:
"@emotion/use-insertion-effect-with-fallbacks": ^1.2.0
"@emotion/utils": ^1.4.2
"@emotion/weak-memoize": ^0.4.0
"@types/hoist-non-react-statics": ^3.3.5
hoist-non-react-statics: ^3.3.1
html-tag-names: ^1.1.2
react: 16.14.0
svg-tag-names: ^1.1.1
Expand Down Expand Up @@ -2970,6 +2968,8 @@ __metadata:
"@emotion/serialize": ^1.3.3
"@emotion/use-insertion-effect-with-fallbacks": ^1.2.0
"@emotion/utils": ^1.4.2
"@types/hoist-non-react-statics": ^3.3.5
hoist-non-react-statics: ^3.3.1
react: 16.14.0
typescript: ^5.4.5
peerDependencies:
Expand Down

0 comments on commit 6158389

Please sign in to comment.