Skip to content

Commit 0934879

Browse files
authored
Codemod to import * as React from "react"; (#18102)
* import * as React from "react"; This is the correct way to import React from an ES module since the ES module will not have a default export. Only named exports. * import * as ReactDOM from "react-dom"
1 parent 78e8160 commit 0934879

File tree

116 files changed

+195
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+195
-142
lines changed

packages/create-subscription/src/createSubscription.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import React from 'react';
10+
import * as React from 'react';
1111
import invariant from 'shared/invariant';
1212

1313
type Unsubscribe = () => void;

packages/react-art/src/ReactART.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React from 'react';
8+
import * as React from 'react';
99
import ReactVersion from 'shared/ReactVersion';
1010
import {LegacyRoot} from 'shared/ReactRootTags';
1111
import {

packages/react-cache/src/ReactCache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import React from 'react';
10+
import * as React from 'react';
1111

1212
import {createLRU} from './LRU';
1313

packages/react-devtools-inline/src/frontend.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @flow */
22

3-
import React, {forwardRef} from 'react';
3+
import * as React from 'react';
4+
import {forwardRef} from 'react';
45
import Bridge from 'react-devtools-shared/src/bridge';
56
import Store from 'react-devtools-shared/src/devtools/store';
67
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';

packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
* @flow
88
*/
99

10-
import React, {
11-
useContext,
12-
useEffect,
13-
useLayoutEffect,
14-
useRef,
15-
useState,
16-
} from 'react';
10+
import * as React from 'react';
11+
import {useContext, useEffect, useLayoutEffect, useRef, useState} from 'react';
1712
import {createPortal} from 'react-dom';
1813
import {RegistryContext} from './Contexts';
1914

packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenuItem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @flow
88
*/
99

10-
import React, {useContext} from 'react';
10+
import * as React from 'react';
11+
import {useContext} from 'react';
1112
import {RegistryContext} from './Contexts';
1213

1314
import styles from './ContextMenuItem.css';

packages/react-devtools-shared/src/devtools/cache.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @flow
88
*/
99

10-
import React, {createContext} from 'react';
10+
import * as React from 'react';
11+
import {createContext} from 'react';
1112

1213
// Cache implementation was forked from the React repo:
1314
// https://github.com/facebook/react/blob/master/packages/react-cache/src/ReactCache.js

packages/react-devtools-shared/src/devtools/views/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import React from 'react';
10+
import * as React from 'react';
1111
import Tooltip from '@reach/tooltip';
1212

1313
import styles from './Button.css';

packages/react-devtools-shared/src/devtools/views/ButtonIcon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import React from 'react';
10+
import * as React from 'react';
1111
import styles from './ButtonIcon.css';
1212

1313
export type IconType =

packages/react-devtools-shared/src/devtools/views/Components/Badge.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @flow
88
*/
99

10-
import React, {Fragment} from 'react';
10+
import * as React from 'react';
11+
import {Fragment} from 'react';
1112
import {
1213
ElementTypeMemo,
1314
ElementTypeForwardRef,

0 commit comments

Comments
 (0)