From e6f79f1d6405bfa3fcbffda6d6990dc359b690b6 Mon Sep 17 00:00:00 2001 From: William Cunningham Date: Tue, 14 Feb 2017 23:58:54 -0500 Subject: [PATCH] Move `getNextDebugID()` to React package. The module, and its internal state, was duplicated in several packages, leading to duplicate ids when multiple renderers were used. --- grunt/config/browserify.js | 1 + gulpfile.js | 2 ++ .../utils => isomorphic}/getNextDebugID.js | 0 .../reconciler/instantiateReactComponent.js | 2 +- src/test/ReactShallowRenderer.js | 2 +- src/umd/ReactUMDEntry.js | 1 + src/umd/ReactWithAddonsUMDEntry.js | 1 + src/umd/shims/getNextDebugIDUMDShim.js | 19 +++++++++++++++++++ 8 files changed, 26 insertions(+), 2 deletions(-) rename src/{shared/utils => isomorphic}/getNextDebugID.js (100%) create mode 100644 src/umd/shims/getNextDebugIDUMDShim.js diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 5cc3f1f840a76..cff70af4057ca 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -18,6 +18,7 @@ var shimSharedModules = aliasify.configure({ 'react/lib/React': 'react/lib/ReactUMDShim', 'react/lib/ReactCurrentOwner': 'react/lib/ReactCurrentOwnerUMDShim', 'react/lib/ReactComponentTreeHook': 'react/lib/ReactComponentTreeHookUMDShim', + 'react/lib/getNextDebugID': 'react/lib/getNextDebugIDUMDShim', }, }); diff --git a/gulpfile.js b/gulpfile.js index 8cacc6534361e..be8ba4cbb0807 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -127,6 +127,7 @@ var moduleMapReact = Object.assign( 'react/lib/checkPropTypes': './checkPropTypes', 'react/lib/ReactComponentTreeHook': './ReactComponentTreeHook', 'react/lib/ReactDebugCurrentFrame': './ReactDebugCurrentFrame', + 'react/lib/getNextDebugID': './getNextDebugID', }, moduleMapBase ); @@ -139,6 +140,7 @@ var rendererSharedState = { 'react/lib/checkPropTypes': 'react/lib/checkPropTypes', 'react/lib/ReactComponentTreeHook': 'react/lib/ReactComponentTreeHook', 'react/lib/ReactDebugCurrentFrame': 'react/lib/ReactDebugCurrentFrame', + 'react/lib/getNextDebugID': 'react/lib/getNextDebugID', }; var moduleMapReactDOM = Object.assign( diff --git a/src/shared/utils/getNextDebugID.js b/src/isomorphic/getNextDebugID.js similarity index 100% rename from src/shared/utils/getNextDebugID.js rename to src/isomorphic/getNextDebugID.js diff --git a/src/renderers/shared/stack/reconciler/instantiateReactComponent.js b/src/renderers/shared/stack/reconciler/instantiateReactComponent.js index 4fab1a3b200f3..54bcca6baaa09 100644 --- a/src/renderers/shared/stack/reconciler/instantiateReactComponent.js +++ b/src/renderers/shared/stack/reconciler/instantiateReactComponent.js @@ -15,7 +15,7 @@ var ReactCompositeComponent = require('ReactCompositeComponent'); var ReactEmptyComponent = require('ReactEmptyComponent'); var ReactHostComponent = require('ReactHostComponent'); -var getNextDebugID = require('getNextDebugID'); +var getNextDebugID = require('react/lib/getNextDebugID'); var invariant = require('fbjs/lib/invariant'); var warning = require('fbjs/lib/warning'); diff --git a/src/test/ReactShallowRenderer.js b/src/test/ReactShallowRenderer.js index 6e70f9b99da01..a698efc52c14a 100644 --- a/src/test/ReactShallowRenderer.js +++ b/src/test/ReactShallowRenderer.js @@ -20,7 +20,7 @@ var ReactReconciler = require('ReactReconciler'); var ReactUpdates = require('ReactUpdates'); var emptyObject = require('fbjs/lib/emptyObject'); -var getNextDebugID = require('getNextDebugID'); +var getNextDebugID = require('react/lib/getNextDebugID'); var invariant = require('fbjs/lib/invariant'); class NoopInternalComponent { diff --git a/src/umd/ReactUMDEntry.js b/src/umd/ReactUMDEntry.js index ab926354a63de..36c4fd75cf732 100644 --- a/src/umd/ReactUMDEntry.js +++ b/src/umd/ReactUMDEntry.js @@ -26,6 +26,7 @@ if (__DEV__) { { // ReactComponentTreeHook should not be included in production. ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'), + getNextDebugID: require('react/lib/getNextDebugID'), } ); } diff --git a/src/umd/ReactWithAddonsUMDEntry.js b/src/umd/ReactWithAddonsUMDEntry.js index c36ade28a98e5..6d943faf8ad7d 100644 --- a/src/umd/ReactWithAddonsUMDEntry.js +++ b/src/umd/ReactWithAddonsUMDEntry.js @@ -27,6 +27,7 @@ if (__DEV__) { { // ReactComponentTreeHook should not be included in production. ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'), + getNextDebugID: require('react/lib/getNextDebugID'), } ); } diff --git a/src/umd/shims/getNextDebugIDUMDShim.js b/src/umd/shims/getNextDebugIDUMDShim.js new file mode 100644 index 0000000000000..3c8855d20501d --- /dev/null +++ b/src/umd/shims/getNextDebugIDUMDShim.js @@ -0,0 +1,19 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getNextDebugId + */ + +/* globals React */ + +'use strict'; + +var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +module.exports = ReactInternals.getNextDebugID; +