Skip to content

Commit

Permalink
Codemod to import * as React from "react"; (#18102)
Browse files Browse the repository at this point in the history
* 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"
sebmarkbage authored Feb 22, 2020
1 parent 78e8160 commit 0934879
Showing 116 changed files with 195 additions and 142 deletions.
2 changes: 1 addition & 1 deletion packages/create-subscription/src/createSubscription.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import invariant from 'shared/invariant';

type Unsubscribe = () => void;
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactART.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import * as React from 'react';
import ReactVersion from 'shared/ReactVersion';
import {LegacyRoot} from 'shared/ReactRootTags';
import {
2 changes: 1 addition & 1 deletion packages/react-cache/src/ReactCache.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';

import {createLRU} from './LRU';

3 changes: 2 additions & 1 deletion packages/react-devtools-inline/src/frontend.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @flow */

import React, {forwardRef} from 'react';
import * as React from 'react';
import {forwardRef} from 'react';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
Original file line number Diff line number Diff line change
@@ -7,13 +7,8 @@
* @flow
*/

import React, {
useContext,
useEffect,
useLayoutEffect,
useRef,
useState,
} from 'react';
import * as React from 'react';
import {useContext, useEffect, useLayoutEffect, useRef, useState} from 'react';
import {createPortal} from 'react-dom';
import {RegistryContext} from './Contexts';

Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useContext} from 'react';
import * as React from 'react';
import {useContext} from 'react';
import {RegistryContext} from './Contexts';

import styles from './ContextMenuItem.css';
3 changes: 2 additions & 1 deletion packages/react-devtools-shared/src/devtools/cache.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {createContext} from 'react';
import * as React from 'react';
import {createContext} from 'react';

// Cache implementation was forked from the React repo:
// https://github.com/facebook/react/blob/master/packages/react-cache/src/ReactCache.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import Tooltip from '@reach/tooltip';

import styles from './Button.css';
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import styles from './ButtonIcon.css';

export type IconType =
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Fragment} from 'react';
import * as React from 'react';
import {Fragment} from 'react';
import {
ElementTypeMemo,
ElementTypeForwardRef,
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Suspense} from 'react';
import * as React from 'react';
import {Suspense} from 'react';
import Tree from './Tree';
import SelectedElement from './SelectedElement';
import {InspectedElementContextController} from './InspectedElementContext';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useCallback, useState} from 'react';
import * as React from 'react';
import {useCallback, useState} from 'react';
import AutoSizeInput from './NativeStyleEditor/AutoSizeInput';
import styles from './EditableName.css';

Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Fragment, useRef} from 'react';
import * as React from 'react';
import {Fragment, useRef} from 'react';
import styles from './EditableValue.css';
import {useEditableValue} from '../hooks';

Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Fragment, useContext, useMemo, useState} from 'react';
import * as React from 'react';
import {Fragment, useContext, useMemo, useState} from 'react';
import Store from 'react-devtools-shared/src/devtools/store';
import Badge from './Badge';
import ButtonIcon from '../ButtonIcon';
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import {
ElementTypeForwardRef,
ElementTypeMemo,
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
*/

import {copy} from 'clipboard-js';
import React, {useCallback, useContext, useRef, useState} from 'react';
import * as React from 'react';
import {useCallback, useContext, useRef, useState} from 'react';
import {BridgeContext, StoreContext} from '../context';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useCallback, useContext, useEffect, useState} from 'react';
import * as React from 'react';
import {useCallback, useContext, useEffect, useState} from 'react';
import {BridgeContext} from '../context';
import Toggle from '../Toggle';
import ButtonIcon from '../ButtonIcon';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {
import * as React from 'react';
import {
createContext,
useCallback,
useContext,
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
*/

import {copy} from 'clipboard-js';
import React, {useCallback, useState} from 'react';
import * as React from 'react';
import {useCallback, useState} from 'react';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import KeyValue from './KeyValue';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useEffect, useRef, useState} from 'react';
import * as React from 'react';
import {useEffect, useRef, useState} from 'react';
import EditableValue from './EditableValue';
import ExpandCollapseToggle from './ExpandCollapseToggle';
import {alphaSortEntries, getMetaValueLabel} from '../utils';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Fragment, useLayoutEffect, useRef} from 'react';
import * as React from 'react';
import {Fragment, useLayoutEffect, useRef} from 'react';
import styles from './AutoSizeInput.css';

type Props = {
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import styles from './LayoutViewer.css';

import type {Layout} from './types';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useContext, useMemo, useRef, useState} from 'react';
import * as React from 'react';
import {useContext, useMemo, useRef, useState} from 'react';
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
import {copy} from 'clipboard-js';
import {
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {
import * as React from 'react';
import {
createContext,
useCallback,
useContext,
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Fragment, useContext, useMemo} from 'react';
import * as React from 'react';
import {Fragment, useContext, useMemo} from 'react';
import {StoreContext} from 'react-devtools-shared/src/devtools/views/context';
import {useSubscription} from 'react-devtools-shared/src/devtools/views/hooks';
import {NativeStyleContext} from './context';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {createContext, useCallback, useContext, useEffect} from 'react';
import * as React from 'react';
import {createContext, useCallback, useContext, useEffect} from 'react';
import {createResource} from '../../cache';
import {BridgeContext, StoreContext} from '../context';
import {TreeStateContext} from './TreeContext';
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@
*
* @flow
*/
import React, {
import * as React from 'react';
import {
Fragment,
useCallback,
useContext,
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useCallback, useContext, useEffect, useRef} from 'react';
import * as React from 'react';
import {useCallback, useContext, useEffect, useRef} from 'react';
import {TreeDispatcherContext, TreeStateContext} from './TreeContext';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
*/

import {copy} from 'clipboard-js';
import React, {Fragment, useCallback, useContext} from 'react';
import * as React from 'react';
import {Fragment, useCallback, useContext} from 'react';
import {TreeDispatcherContext, TreeStateContext} from './TreeContext';
import {BridgeContext, ContextMenuContext, StoreContext} from '../context';
import ContextMenu from '../../ContextMenu/ContextMenu';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useContext, useMemo} from 'react';
import * as React from 'react';
import {useContext, useMemo} from 'react';
import {TreeStateContext} from './TreeContext';
import {SettingsContext} from '../Settings/SettingsContext';
import TreeFocusedContext from './TreeFocusedContext';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {
import * as React from 'react';
import {
Fragment,
Suspense,
useCallback,
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@
// For this reason, changes to the tree context are processed in sequence: tree -> search -> owners
// This enables each section to potentially override (or mask) previous values.

import React, {
import * as React from 'react';
import {
createContext,
useCallback,
useContext,
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@
import '@reach/menu-button/styles.css';
import '@reach/tooltip/styles.css';

import React, {useEffect, useMemo, useState} from 'react';
import * as React from 'react';
import {useEffect, useMemo, useState} from 'react';
import Store from '../store';
import {BridgeContext, ContextMenuContext, StoreContext} from './context';
import Components from './Components/Components';
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {Component} from 'react';
import * as React from 'react';
import {Component} from 'react';
import styles from './ErrorBoundary.css';

type Props = {|
2 changes: 1 addition & 1 deletion packages/react-devtools-shared/src/devtools/views/Icon.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';
import styles from './Icon.css';

export type IconType =
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {
import * as React from 'react';
import {
createContext,
useCallback,
useContext,
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* @flow
*/

import React from 'react';
import * as React from 'react';

import styles from './ChartNode.css';

Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
* @flow
*/

import React, {useCallback, useContext} from 'react';
import * as React from 'react';
import {useCallback, useContext} from 'react';
import {ProfilerContext} from './ProfilerContext';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
Loading

0 comments on commit 0934879

Please sign in to comment.