From 01bf1970c67bb0edf5513ad62abd485993cdfa01 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 4 Mar 2020 20:43:34 -0800 Subject: [PATCH] Move constants to shared Apparently we can't depend on react/src/ because the whole package is considered "external" as far as rollup is concerned. --- .../react-dom/src/server/ReactPartialRenderer.js | 2 +- .../src/ReactFiberLazyComponent.js | 2 +- packages/react/src/ReactLazy.js | 7 +------ packages/shared/ReactLazyComponent.js | 7 ++++++- packages/shared/ReactLazyStatusTags.js | 14 ++++++++++++++ 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 packages/shared/ReactLazyStatusTags.js diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index bf77e7b325fed..a28b41fc12c90 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -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, diff --git a/packages/react-reconciler/src/ReactFiberLazyComponent.js b/packages/react-reconciler/src/ReactFiberLazyComponent.js index 9507ae67dfe53..394b35ae906d8 100644 --- a/packages/react-reconciler/src/ReactFiberLazyComponent.js +++ b/packages/react-reconciler/src/ReactFiberLazyComponent.js @@ -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 { diff --git a/packages/react/src/ReactLazy.js b/packages/react/src/ReactLazy.js index f4633660f723e..1de3189c923c6 100644 --- a/packages/react/src/ReactLazy.js +++ b/packages/react/src/ReactLazy.js @@ -43,18 +43,13 @@ export type LazyComponent = | ResolvedLazyComponent | RejectedLazyComponent; -export const Uninitialized = -1; -export const Pending = 0; -export const Resolved = 1; -export const Rejected = 2; - export function lazy( ctor: () => Thenable<{default: T, ...} | T, mixed>, ): LazyComponent { let lazyType: LazyComponent = { $$typeof: REACT_LAZY_TYPE, // React uses these fields to store the result. - _status: Uninitialized, + _status: -1, _result: ctor, }; diff --git a/packages/shared/ReactLazyComponent.js b/packages/shared/ReactLazyComponent.js index 5ecc5aae210ab..24b360a1e57a1 100644 --- a/packages/shared/ReactLazyComponent.js +++ b/packages/shared/ReactLazyComponent.js @@ -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( lazyComponent: LazyComponent, diff --git a/packages/shared/ReactLazyStatusTags.js b/packages/shared/ReactLazyStatusTags.js new file mode 100644 index 0000000000000..8baa0ad217248 --- /dev/null +++ b/packages/shared/ReactLazyStatusTags.js @@ -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;