Skip to content

Commit

Permalink
DevTools imports (#24163)
Browse files Browse the repository at this point in the history
* Update DevTools imports: react-dom -> react-dom/client
* Silence ReactDOM.render warning in DevTools test shell
  • Loading branch information
Brian Vaughn authored and rickhanlonii committed Apr 14, 2022
1 parent 6c7fd98 commit 840df99
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
5 changes: 1 addition & 4 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
*/

import {createElement} from 'react';
import {
// $FlowFixMe Flow does not yet know about flushSync()
flushSync,
} from 'react-dom';
import {flushSync} from 'react-dom';
import {createRoot} from 'react-dom/client';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
Expand Down
3 changes: 2 additions & 1 deletion packages/react-devtools-extensions/src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* global chrome */

import {createElement} from 'react';
import {createRoot, flushSync} from 'react-dom';
import {flushSync} from 'react-dom';
import {createRoot} from 'react-dom/client';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
import {getBrowserName, getBrowserTheme} from './utils';
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shell/src/app/Iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as React from 'react';
import {Fragment} from 'react';
import * as ReactDOM from 'react-dom';
import {createPortal} from 'react-dom';

export default function Iframe() {
return (
Expand Down Expand Up @@ -56,7 +56,7 @@ function Frame(props) {
style={iframeStyle}
/>

{element ? ReactDOM.createPortal(props.children, element) : null}
{element ? createPortal(props.children, element) : null}
</Fragment>
);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react-devtools-shell/src/app/devtools.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/** @flow */

import {createElement} from 'react';
// $FlowFixMe Flow does not yet know about createRoot()
import {createRoot} from 'react-dom';
import {createRoot} from 'react-dom/client';
import {
activate as activateBackend,
initialize as initializeBackend,
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-shell/src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ignoreErrors([
'Warning: Legacy context API',
'Warning: Unsafe lifecycle methods',
'Warning: %s is deprecated in StrictMode.', // findDOMNode
'Warning: ReactDOM.render is no longer supported in React 18',
]);
ignoreWarnings(['Warning: componentWillReceiveProps has been renamed']);
ignoreLogs([]);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shell/src/e2e/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOMClient from 'react-dom/client';
import {createRoot} from 'react-dom/client';

const container = document.createElement('div');

Expand All @@ -14,7 +14,7 @@ const container = document.createElement('div');
// so that it can load things other than just ToDoList.
const App = require('./apps/ListApp').default;

const root = ReactDOMClient.createRoot(container);
const root = createRoot(container);
root.render(<App />);

// ReactDOM Test Selector APIs used by Playwright e2e tests
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shell/src/e2e/devtools.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOMClient from 'react-dom/client';
import {createRoot} from 'react-dom/client';
import {
activate as activateBackend,
initialize as initializeBackend,
Expand Down Expand Up @@ -34,7 +34,7 @@ function init(appIframe, devtoolsContainer, appSource) {

inject(contentDocument, appSource, () => {
// $FlowFixMe Flow doesn't know about createRoot() yet.
ReactDOMClient.createRoot(devtoolsContainer).render(
createRoot(devtoolsContainer).render(
<DevTools
hookNamesModuleLoaderFunction={hookNamesModuleLoaderFunction}
showTabBar={true}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-shell/src/multi/devtools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {createRoot} from 'react-dom';
import {createRoot} from 'react-dom/client';
import {
activate as activateBackend,
createBridge as createBackendBridge,
Expand Down

0 comments on commit 840df99

Please sign in to comment.