Skip to content

Commit

Permalink
Move constants to shared
Browse files Browse the repository at this point in the history
Apparently we can't depend on react/src/ because the whole package is
considered "external" as far as rollup is concerned.
  • Loading branch information
sebmarkbage committed Mar 5, 2020
1 parent 326c710 commit 01bf197
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import getComponentName from 'shared/getComponentName';
import describeComponentFrame from 'shared/describeComponentFrame';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {initializeLazyComponentType} from 'shared/ReactLazyComponent';
import {Resolved, Rejected, Pending} from 'react/src/ReactLazy';
import {Resolved, Rejected, Pending} from 'shared/ReactLazyStatusTags';
import {
warnAboutDeprecatedLifecycles,
disableLegacyContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberLazyComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {LazyComponent} from 'react/src/ReactLazy';

import {Resolved} from 'react/src/ReactLazy';
import {Resolved} from 'shared/ReactLazyStatusTags';
import {initializeLazyComponentType} from 'shared/ReactLazyComponent';

export function resolveDefaultProps(Component: any, baseProps: Object): Object {
Expand Down
7 changes: 1 addition & 6 deletions packages/react/src/ReactLazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ export type LazyComponent<T> =
| ResolvedLazyComponent<T>
| RejectedLazyComponent;

export const Uninitialized = -1;
export const Pending = 0;
export const Resolved = 1;
export const Rejected = 2;

export function lazy<T>(
ctor: () => Thenable<{default: T, ...} | T, mixed>,
): LazyComponent<T> {
let lazyType: LazyComponent<T> = {
$$typeof: REACT_LAZY_TYPE,
// React uses these fields to store the result.
_status: Uninitialized,
_status: -1,
_result: ctor,
};

Expand Down
7 changes: 6 additions & 1 deletion packages/shared/ReactLazyComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import type {
LazyComponent,
} from 'react/src/ReactLazy';

import {Uninitialized, Pending, Resolved, Rejected} from 'react/src/ReactLazy';
import {
Uninitialized,
Pending,
Resolved,
Rejected,
} from './ReactLazyStatusTags';

export function refineResolvedLazyComponent<T>(
lazyComponent: LazyComponent<T>,
Expand Down
14 changes: 14 additions & 0 deletions packages/shared/ReactLazyStatusTags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// TODO: Move this to "react" once we can import from externals.
export const Uninitialized = -1;
export const Pending = 0;
export const Resolved = 1;
export const Rejected = 2;

0 comments on commit 01bf197

Please sign in to comment.