added guards in place to prevent mixed prod+dev errors from occuring

This commit is contained in:
Dominic Gannaway 2017-03-02 23:06:32 +00:00
parent 397fd2b92e
commit 91de17ec52
5 changed files with 19 additions and 24 deletions

View File

@ -38,7 +38,7 @@ if (__DEV__) {
if (typeof current === 'number') {
// DebugID from Stack.
const debugID = current;
stack = getStackAddendumByID(debugID);
stack = getStackAddendumByID && getStackAddendumByID(debugID);
} else if (typeof current.tag === 'number') {
// This is a Fiber.
// The stack will only be correct if this is a work in progress
@ -47,7 +47,7 @@ if (__DEV__) {
stack = getStackAddendumByWorkInProgressFiber(workInProgress);
}
} else if (element !== null) {
stack = getCurrentStackAddendum(element);
stack = getCurrentStackAddendum && getCurrentStackAddendum(element);
}
return stack;
};

View File

@ -120,7 +120,9 @@ if (__DEV__) {
var lifeCycleTimerHasWarned = false;
const clearHistory = function() {
if (purgeUnmountedComponents) {
purgeUnmountedComponents();
}
ReactHostOperationHistoryHook.clearHistory();
};
@ -156,6 +158,7 @@ if (__DEV__) {
}
if (previousMeasurements.length || previousOperations.length) {
if (getRegisteredIDs) {
var registeredIDs = getRegisteredIDs();
flushHistory.push({
@ -165,6 +168,7 @@ if (__DEV__) {
treeSnapshot: getTreeSnapshot(registeredIDs),
});
}
}
clearHistory();
currentFlushStartTime = performanceNow();
@ -266,7 +270,7 @@ if (__DEV__) {
if (!isProfiling || !canUsePerformanceMeasure) {
return false;
}
var element = getElement(debugID);
var element = getElement && getElement(debugID);
if (element == null || typeof element !== 'object') {
return false;
}
@ -293,7 +297,7 @@ if (__DEV__) {
}
var markName = `${debugID}::${markType}`;
var displayName = getDisplayName(debugID) || 'Unknown';
var displayName = getDisplayName && getDisplayName(debugID) || 'Unknown';
// Chrome has an issue of dropping markers recorded too fast:
// https://bugs.chromium.org/p/chromium/issues/detail?id=640652

View File

@ -49,7 +49,7 @@ function attachRef(ref, component, owner) {
if (element && element._source) {
warningKey = element._source.fileName + ':' + element._source.lineNumber;
}
if (!warnedAboutStatelessRefs[warningKey]) {
if (!warnedAboutStatelessRefs[warningKey] && getStackAddendumByID) {
warnedAboutStatelessRefs[warningKey] = true;
warning(
false,

View File

@ -55,7 +55,7 @@ function flattenSingleChildIntoContext(
}
const { getStackAddendumByID }: ComponentTreeHookDevType = (ReactComponentTreeHook: any);
if (!keyUnique) {
if (!keyUnique && getStackAddendumByID) {
warning(
false,
'flattenChildren(...): Encountered two children with the same key, ' +

View File

@ -17,17 +17,8 @@ var React = require('React');
var ReactUMDEntry = Object.assign({
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
ReactCurrentOwner: require('react/lib/ReactCurrentOwner'),
ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'),
},
}, React);
if (__DEV__) {
Object.assign(
ReactUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
{
// ReactComponentTreeHook should not be included in production.
ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'),
}
);
}
module.exports = ReactUMDEntry;