Skip to content

Commit 07353f9

Browse files
authored
Fixed benchmarks app (#3297)
* Fixed benchmarks app * update snapshot
1 parent d3056ac commit 07353f9

File tree

12 files changed

+33
-38
lines changed

12 files changed

+33
-38
lines changed

babel.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let isTestFile = filename =>
1010
module.exports = api => {
1111
api.cache(true)
1212
return {
13-
presets: ['babel-preset-emotion-dev', '@babel/preset-typescript'],
13+
presets: [emotionDevPreset, '@babel/preset-typescript'],
1414
overrides: [
1515
{
1616
test: filename =>
@@ -49,6 +49,15 @@ module.exports = api => {
4949
{ runtime: 'automatic', development: true, useEmotionPlugin: true }
5050
]
5151
]
52+
},
53+
{
54+
test: filename => filename && filename.includes('scripts/benchmarks'),
55+
presets: [
56+
[
57+
emotionDevPreset,
58+
{ runtime: 'automatic', development: false, useEmotionPlugin: true }
59+
]
60+
]
5261
}
5362
]
5463
}

docs/ssr.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,16 @@ index.js
265265
```jsx
266266
// This has to be run before emotion inserts any styles so it's imported before the App component
267267
import './disable-speedy'
268-
import ReactDOM from 'react-dom'
268+
import { createRoot, hydrateRoot } from 'react-dom/client'
269269
import App from './App'
270270

271271
const root = document.getElementById('root')
272272

273273
// Check if the root node has any children to detect if the app has been prerendered
274274
if (root.hasChildNodes()) {
275-
ReactDOM.hydrate(<App />, root)
275+
hydrateRoot(root, <App />)
276276
} else {
277-
ReactDOM.render(<App />, root)
277+
createRoot(root).render(<App />)
278278
}
279279
```
280280

packages/babel-plugin-jsx-pragmatic/__tests__/__fixtures__/existing-imports.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'react-app-polyfill/ie11'
33
import 'react-app-polyfill/stable'
44

55
import React from 'react'
6-
import ReactDOM from 'react-dom'
6+
import { createRoot } from 'react-dom/client'
77
import App from './App'
88

9-
ReactDOM.render(<App />, document.getElementById('root'))
9+
createRoot(document.getElementById('root')).render(<App />)

packages/babel-plugin-jsx-pragmatic/__tests__/__snapshots__/index.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import 'react-app-polyfill/ie11'
66
import 'react-app-polyfill/stable'
77
88
import React from 'react'
9-
import ReactDOM from 'react-dom'
9+
import { createRoot } from 'react-dom/client'
1010
import App from './App'
1111
12-
ReactDOM.render(<App />, document.getElementById('root'))
12+
createRoot(document.getElementById('root')).render(<App />)
1313
1414
1515
↓ ↓ ↓ ↓ ↓ ↓
@@ -18,10 +18,10 @@ ReactDOM.render(<App />, document.getElementById('root'))
1818
import 'react-app-polyfill/ie11';
1919
import 'react-app-polyfill/stable';
2020
import React from 'react';
21-
import ReactDOM from 'react-dom';
21+
import { createRoot } from 'react-dom/client';
2222
import App from './App';
2323
import { jsx as ___EmotionJSX } from "@emotion/react";
24-
ReactDOM.render(<App />, document.getElementById('root'));"
24+
createRoot(document.getElementById('root')).render(<App />);"
2525
`;
2626

2727
exports[`@emotion/babel-plugin-jsx-pragmatic fragment-only 1`] = `

playgrounds/cra/src/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react'
2-
import ReactDOM from 'react-dom'
2+
import { createRoot, hydrateRoot } from 'react-dom/client'
33
import App from './App'
44

5-
ReactDOM.render(
5+
createRoot(document.getElementById('root')).render(
66
<React.StrictMode>
77
<App />
8-
</React.StrictMode>,
9-
document.getElementById('root')
8+
</React.StrictMode>
109
)

scripts/benchmarks/.babelrc

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/benchmarks/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
},
2323
"alias": {
2424
"react-native": "react-native-web"
25+
},
26+
"@parcel/resolver-default": {
27+
"packageExports": true
2528
}
2629
}

scripts/benchmarks/src/app/Text.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import { colors } from './theme'
88
class AppText extends React.Component {
99
static displayName = '@app/Text'
1010

11-
static contextTypes = {
12-
isInAParentText: bool
13-
}
14-
1511
render() {
1612
const { style, ...rest } = this.props
1713
const { isInAParentText } = this.context

scripts/benchmarks/src/implementations/emotion-css-prop/Box.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/** @jsx jsx */
1+
/** @jsxImportSource @emotion/react */
22
import { viewStyle } from './View'
3-
import { css, jsx } from '@emotion/react'
3+
import { css } from '@emotion/react'
44

55
const Box = ({
66
color,

scripts/benchmarks/src/implementations/emotion-css-prop/Dot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/** @jsx jsx */
2-
import { css, jsx } from '@emotion/react'
1+
/** @jsxImportSource @emotion/react */
2+
import { css } from '@emotion/react'
33

44
const Dot = ({ size, x, y, children, color }) => (
55
<div

scripts/benchmarks/src/implementations/emotion-css-prop/View.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/** @jsx jsx */
2-
import { css, jsx } from '@emotion/react'
1+
/** @jsxImportSource @emotion/react */
2+
import { css } from '@emotion/react'
33

44
const View = ({ style, ...other }) => {
55
return <div {...other} css={css(viewStyle, style)} />

scripts/benchmarks/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Tree from './cases/Tree'
44
import SierpinskiTriangle from './cases/SierpinskiTriangle'
55

66
import React from 'react'
7-
import ReactDOM from 'react-dom'
7+
import { createRoot } from 'react-dom/client'
88

99
const packageNames = Object.keys(implementations)
1010

@@ -76,4 +76,4 @@ if (!root) {
7676
throw new Error('could not find root')
7777
}
7878

79-
ReactDOM.render(<App tests={tests} />, root)
79+
createRoot(root).render(<App tests={tests} />)

0 commit comments

Comments
 (0)