Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shares debugID information across modules #8097

Merged
merged 1 commit into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var ReactCompositeComponent = require('ReactCompositeComponent');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactHostComponent = require('ReactHostComponent');

var getNextDebugID = require('getNextDebugID');
var invariant = require('invariant');
var warning = require('warning');

Expand Down Expand Up @@ -56,8 +57,6 @@ function isInternalComponentType(type) {
);
}

var nextDebugID = 1;

/**
* Given a ReactNode, create an instance that will actually be mounted.
*
Expand Down Expand Up @@ -125,7 +124,7 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
instance._mountImage = null;

if (__DEV__) {
instance._debugID = shouldHaveDebugID ? nextDebugID++ : 0;
instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
}

// Internal instances should fully constructed at this point, so they should
Expand Down
21 changes: 21 additions & 0 deletions src/shared/utils/getNextDebugID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* 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
* @flow
*/

'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add the header document comment here like the other files (example).

Without the @providesModule comment the haste module system doesn't know where to find this file and tests fail.

Copy link
Contributor Author

@goatslacker goatslacker Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


var nextDebugID = 1;

function getNextDebugID(): number {
return nextDebugID++;
}

module.exports = getNextDebugID;
7 changes: 3 additions & 4 deletions src/test/ReactShallowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ var ReactReconciler = require('ReactReconciler');
var ReactUpdates = require('ReactUpdates');

var emptyObject = require('emptyObject');
var getNextDebugID = require('getNextDebugID');
var invariant = require('invariant');

var nextDebugID = 1;

class NoopInternalComponent {
constructor(element) {
this._renderedOutput = element;
this._currentElement = element;

if (__DEV__) {
this._debugID = nextDebugID++;
this._debugID = getNextDebugID();
}
}
mountComponent() {}
Expand All @@ -50,7 +49,7 @@ class NoopInternalComponent {
var ShallowComponentWrapper = function(element) {
// TODO: Consolidate with instantiateReactComponent
if (__DEV__) {
this._debugID = nextDebugID++;
this._debugID = getNextDebugID();
}

this.construct(element);
Expand Down