Skip to content

Commit fbfe594

Browse files
committed
Migrate to import * as React from 'react';
Ref facebook/react#18102 Also migrated from `import { type Node } from 'react';` to `React.Node` as more explicit because `Node` is also DOM type and may conflict when import is forgotted.
1 parent 4e36611 commit fbfe594

File tree

182 files changed

+264
-212
lines changed

Some content is hidden

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

182 files changed

+264
-212
lines changed

csp-server/app.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// It matches
33
/* eslint-disable flowtype/require-valid-file-annotation */
44

5-
import React, { Component } from 'react';
5+
import * as React from 'react';
6+
import { Component } from 'react';
67
import PropTypes from 'prop-types';
78
import { DragDropContext, Droppable, Draggable } from '../src';
89

csp-server/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
/* eslint-env browser */
33

4-
import React from 'react';
4+
import * as React from 'react';
55
import { hydrate } from 'react-dom';
66
import Sample from './app';
77

csp-server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22
import express from 'express';
3-
import React from 'react';
3+
import * as React from 'react';
44
import { renderToString } from 'react-dom/server';
55
import { resolve } from 'path';
66
import App from './app';

docs/api/drag-drop-context.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Props = {|
4343
### Using a `class` component
4444
4545
```js
46-
import React from 'react';
46+
import * as React from 'react';
4747
import { DragDropContext } from 'react-beautiful-dnd';
4848

4949
class App extends React.Component {
@@ -84,7 +84,7 @@ class App extends React.Component {
8484
### Using a `function` component
8585

8686
```js
87-
import React from 'react';
87+
import * as React from 'react';
8888
import { DragDropContext } from 'react-beautiful-dnd';
8989

9090
function App() {

docs/api/droppable.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ When a user drags over, or stops dragging over, a `<Droppable />` we re-render t
220220
Here is an example of how you could do this using `class` components:
221221
222222
```js
223-
import React, { Component } from 'react';
223+
import * as React from 'react';
224224

225-
class Student extends Component<{ student: Person }> {
225+
class Student extends React.Component<{ student: Person }> {
226226
render() {
227227
// Renders out a draggable student
228228
}
229229
}
230230

231-
class InnerList extends Component<{ students: Person[] }> {
231+
class InnerList extends React.Component<{ students: Person[] }> {
232232
// do not re-render if the students list has not changed
233233
shouldComponentUpdate(nextProps: Props) {
234234
if (this.props.students === nextProps.students) {
@@ -246,7 +246,7 @@ class InnerList extends Component<{ students: Person[] }> {
246246
}
247247
}
248248

249-
class Students extends Component<{ students: Person[] }> {
249+
class Students extends React.Component<{ students: Person[] }> {
250250
render() {
251251
return (
252252
<Droppable droppableId="list">
@@ -271,7 +271,7 @@ class Students extends Component<{ students: Person[] }> {
271271
Here is an example of how you could do this using `function` components:
272272

273273
```js
274-
import React from 'react';
274+
import * as React from 'react';
275275

276276
function Student (props: { student: Person }) {
277277
// Renders out a draggable student

src/view/animate-in-out/animate-in-out.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React, { type Node } from 'react';
2+
import * as React from 'react';
33
import type { InOutAnimationMode } from '../../types';
44

55
export type AnimateProvided = {|
@@ -11,7 +11,7 @@ export type AnimateProvided = {|
1111
type Props = {|
1212
on: mixed,
1313
shouldAnimate: boolean,
14-
children: (provided: AnimateProvided) => Node,
14+
children: (provided: AnimateProvided) => React.Node,
1515
|};
1616

1717
type State = {|

src/view/context/app-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import type { DraggableId, ContextId, ElementId } from '../../types';
44
import type { DimensionMarshal } from '../../state/dimension-marshal/dimension-marshal-types';
55
import type { FocusMarshal } from '../use-focus-marshal/focus-marshal-types';

src/view/context/droppable-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import type { DraggableId, DroppableId, TypeId } from '../../types';
44

55
export type DroppableContextValue = {|

src/view/context/store-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import type { Store } from '../../state/store-types';
44

55
export default React.createContext<?Store>(null);

src/view/drag-drop-context/app.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @flow
2-
import React, { useEffect, useRef, type Node } from 'react';
2+
import * as React from 'react';
3+
import { useEffect, useRef } from 'react';
34
import { bindActionCreators } from 'redux';
45
import { Provider } from 'react-redux';
56
import { useMemo, useCallback } from 'use-memo-one';
@@ -55,7 +56,7 @@ export type Props = {|
5556
setCallbacks: SetAppCallbacks,
5657
nonce?: string,
5758
// we do not technically need any children for this component
58-
children: Node | null,
59+
children: React.Node | null,
5960

6061
// sensors
6162
sensors?: Sensor[],

src/view/drag-drop-context/drag-drop-context.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React, { type Node } from 'react';
2+
import * as React from 'react';
33
import type { Responders, ContextId, Sensor } from '../../types';
44
import ErrorBoundary from './error-boundary';
55
import preset from '../../screen-reader-message-preset';
@@ -12,7 +12,7 @@ import { reset as resetUniqueIds } from '../use-unique-id';
1212
type Props = {|
1313
...Responders,
1414
// We do not technically need any children for this component
15-
children: Node | null,
15+
children: React.Node | null,
1616
// Read out by screen readers when focusing on a drag handle
1717
dragHandleUsageInstructions?: string,
1818
// Used for strict content security policies

src/view/drag-drop-context/error-boundary.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// @flow
2-
import React, { type Node } from 'react';
2+
import * as React from 'react';
33
import { warning, error } from '../../dev-warning';
44
import { noop } from '../../empty';
55
import bindEvents from '../event-bindings/bind-events';
66
import { RbdInvariant } from '../../invariant';
77
import type { AppCallbacks } from './drag-drop-context-types';
88

99
type Props = {|
10-
children: (setCallbacks: (callbacks: AppCallbacks) => void) => Node,
10+
children: (setCallbacks: (callbacks: AppCallbacks) => void) => React.Node,
1111
|};
1212

1313
// Lame that this is not in flow

src/view/drag-drop-context/use-startup-validation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { peerDependencies } from '../../../package.json';
44
import checkReactVersion from './check-react-version';
55
import checkDoctype from './check-doctype';

src/view/draggable/draggable-api.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import type { DraggableId } from '../../types';
44
import type { PublicOwnProps, PrivateOwnProps } from './draggable-types';
55
import ConnectedDraggable from './connected-draggable';

src/view/droppable/droppable.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// @flow
22
import ReactDOM from 'react-dom';
33
import { useMemo, useCallback } from 'use-memo-one';
4-
import React, { useRef, useContext, type Node } from 'react';
4+
import * as React from 'react';
5+
import { useRef, useContext } from 'react';
56
import { invariant } from '../../invariant';
67
import type { DraggableId } from '../../types';
78
import type { Props, Provided } from './droppable-types';
@@ -89,7 +90,7 @@ export default function Droppable(props: Props) {
8990
getDroppableRef,
9091
});
9192

92-
const placeholder: Node = (
93+
const placeholder: React.Node = (
9394
<AnimateInOut
9495
on={props.placeholder}
9596
shouldAnimate={props.shouldAnimatePlaceholder}
@@ -132,13 +133,13 @@ export default function Droppable(props: Props) {
132133
[droppableId, isUsingCloneFor, type],
133134
);
134135

135-
function getClone(): ?Node {
136+
function getClone(): ?React.Node {
136137
if (!useClone) {
137138
return null;
138139
}
139140
const { dragging, render } = useClone;
140141

141-
const node: Node = (
142+
const node: React.Node = (
142143
<PrivateDraggable
143144
draggableId={dragging.draggableId}
144145
index={dragging.source.index}

src/view/placeholder/placeholder.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @flow
2-
import React, { useState, useRef, useEffect, type Node } from 'react';
2+
import * as React from 'react';
3+
import { useState, useRef, useEffect } from 'react';
34
import { useCallback } from 'use-memo-one';
45
import type { Spacing } from 'css-box-model';
56
import type {
@@ -114,7 +115,7 @@ const getStyle = ({
114115
};
115116
};
116117

117-
function Placeholder(props: Props): Node {
118+
function Placeholder(props: Props): React.Node {
118119
const animateOpenTimerRef = useRef<?TimeoutID>(null);
119120

120121
const tryClearAnimateOpenTimer = useCallback(() => {

stories/1-single-vertical-list.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import styled from '@emotion/styled';
55
import QuoteApp from './src/vertical/quote-app';

stories/10-table.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import WithDimensionLocking from './src/table/with-dimension-locking';
55
import WithFixedColumns from './src/table/with-fixed-columns';

stories/11-portal.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import PortalApp from './src/portal/portal-app';
55
import { quotes } from './src/data';

stories/12-dynamic.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import WithControls from './src/dynamic/with-controls';
55
import LazyLoading from './src/dynamic/lazy-loading';

stories/15-on-before-capture.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import AddingThings from './src/on-before-capture/adding-things';
55

stories/2-single-horizontal.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import styled from '@emotion/styled';
55
import AuthorApp from './src/horizontal/author-app';

stories/20-super-simple.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import Simple from './src/simple/simple';
55
import SimpleWithScroll from './src/simple/simple-scrollable';

stories/21-change-on-drag-start.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import {
55
DragDropContext,

stories/25-fixed-list.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import WithFixedSidebar from './src/fixed-list/fixed-sidebar';
55

stories/3-board.stories.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import Board from './src/board/board';
55
import { authorQuoteMap, generateQuoteMap } from './src/data';

stories/30-custom-drop.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import FunnyDrop from './src/custom-drop/funny-drop';
55
import NoDrop from './src/custom-drop/no-drop';

stories/35-function-component.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import QuoteApp from './src/function-component/quote-app';
55

stories/4-complex-vertical-list.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import NestedQuoteApp from './src/vertical-nested/quote-app';
55
import GroupedQuoteApp from './src/vertical-grouped/quote-app';

stories/40-programmatic.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import WithControls from './src/programmatic/with-controls';
55
import Runsheet from './src/programmatic/runsheet';

stories/45-virtual.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import ReactWindowList from './src/virtual/react-window/list';
55
import ReactVirtualizedList from './src/virtual/react-virtualized/list';

stories/5-multiple-vertical-lists.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import QuoteApp from './src/multiple-vertical/quote-app';
55
import { getQuotes } from './src/data';

stories/50-multiple-contexts.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import MultipleContexts from './src/programmatic/multiple-contexts';
55

stories/55-mixed-sizes.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import MixedSizedItems from './src/mixed-sizes/mixed-size-items';
55
import MixedSizedLists from './src/mixed-sizes/mixed-size-lists';

stories/6-multiple-horizontal-lists.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import QuoteApp from './src/multiple-horizontal/quote-app';
55
import { getQuotes } from './src/data';

stories/7-interactive-elements.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import InteractiveElementsApp from './src/interactive-elements/interactive-elements-app';
55

stories/8-accessibility.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import TaskApp from './src/accessible/task-app';
55

stories/9-multi-drag.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
import TaskApp from './src/multi-drag/task-app';
55

stories/99-debug.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33
import { storiesOf } from '@storybook/react';
44
// import { Draggable, Droppable, DragDropContext } from '../src';
55

0 commit comments

Comments
 (0)