Skip to content

Commit 206fb75

Browse files
edkimmelnecolas
authored andcommitted
[change] React 18 support
* Support React 18 concurrency and constraints. * Add new render / hydrate functions. * Remove uses of findNodeHandle. * Expose ability to unmount an application once ran. Fix #1529 Close #2330
1 parent 16d3c23 commit 206fb75

File tree

35 files changed

+393
-588
lines changed

35 files changed

+393
-588
lines changed

configs/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"settings": {
33
"react": {
44
"pragma": "React",
5-
"version": "17.0",
5+
"version": "18.0",
66
"flowVersion": "0.148.0" // Flow version
77
}
88
},

package-lock.json

Lines changed: 59 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@babel/preset-env": "^7.18.6",
3535
"@babel/preset-flow": "^7.18.6",
3636
"@babel/preset-react": "^7.18.6",
37-
"@testing-library/react": "^12.1.5",
37+
"@testing-library/react": "^13.3.0",
3838
"babel-eslint": "^10.1.0",
3939
"babel-jest": "^28.1.2",
4040
"babel-plugin-add-module-exports": "^1.0.4",

packages/benchmarks/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@ const tests = {
7171
}))
7272
};
7373

74-
ReactDOM.render(<App tests={tests} />, document.querySelector('.root'));
74+
const root = document.querySelector('.root');
75+
const element = <App tests={tests} />;
76+
77+
ReactDOM.createRoot(root).render(element);

packages/react-native-web-docs/src/pages/docs/apis/app-registry.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ If the client should hydrate server-rendered HTML.
6969
The initial props passed to the root component.
7070
{% endcall %}
7171

72+
{% call macro.prop('mode', '"concurrent" | "legacy"') %}
73+
Default is 'concurrent'. Setting to 'legacy' will make the app will behave as if it’s running React 17.
74+
{% endcall %}
75+
7276
{% call macro.prop('rootTag', 'HTMLElement') %}
7377
The native element into which the application is rendered.
7478
{% endcall %}

packages/react-native-web-examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"dependencies": {
1111
"babel-plugin-react-native-web": "0.18.10",
1212
"next": "^12.2.0",
13-
"react": "^17.0.2",
14-
"react-dom": "^17.0.2",
13+
"react": "^18.0.0",
14+
"react-dom": "^18.0.0",
1515
"react-native-web": "0.18.10"
1616
},
1717
"devDependencies": {

packages/react-native-web-examples/pages/app-registry/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ export default function AppStatePage() {
2525
const iframeRootTag = document.createElement('div');
2626
iframeRootTag.id = 'iframe-root';
2727
iframeBody.appendChild(iframeRootTag);
28-
AppRegistry.runApplication('App', { rootTag: iframeRootTag });
28+
const app1 = AppRegistry.runApplication('App', { rootTag: iframeRootTag });
2929

3030
const shadowElement = shadowRef.current;
3131
const shadowRoot = shadowElement.attachShadow({ mode: 'open' });
3232
const shadowRootTag = document.createElement('div');
3333
shadowRootTag.id = 'shadow-root';
3434
shadowRoot.appendChild(shadowRootTag);
35-
AppRegistry.runApplication('App', { rootTag: shadowRootTag });
35+
const app2 = AppRegistry.runApplication('App', { rootTag: shadowRootTag });
3636

3737
return () => {
38-
AppRegistry.unmountApplicationComponentAtRootTag(iframeRootTag);
39-
AppRegistry.unmountApplicationComponentAtRootTag(shadowRootTag);
38+
app1.unmount();
39+
app2.unmount();
4040
};
4141
}, []);
4242

packages/react-native-web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"styleq": "^0.1.2"
3232
},
3333
"peerDependencies": {
34-
"react": "^17.0.2 || ^18.0.0",
35-
"react-dom": "^17.0.2 || ^18.0.0"
34+
"react": "^18.0.0",
35+
"react-dom": "^18.0.0"
3636
},
3737
"author": "Nicolas Gallagher",
3838
"license": "MIT",

packages/react-native-web/src/exports/ActivityIndicator/__tests__/index-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
import ActivityIndicator from '..';
99
import React from 'react';
10-
import { act } from 'react-dom/test-utils';
1110
import { createEventTarget } from 'dom-event-testing-library';
12-
import { render } from '@testing-library/react';
11+
import { act, render } from '@testing-library/react';
1312

1413
describe('components/ActivityIndicator', () => {
1514
describe('prop "accessibilityLabel"', () => {

0 commit comments

Comments
 (0)