mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Wrap warning() calls in a DEV check for RN_* builds too (#10428)
* Wrap warning() calls in a DEV check for RN_* builds too. * Wrapped several warning() imports and calls in if-DEV checks. * Removed a useless variable (allTypesByEventName) and loop from ReactNativeBridgeEventPlugin.
This commit is contained in:
@@ -124,6 +124,8 @@ function updateBabelConfig(babelOpts, bundleType) {
|
||||
switch (bundleType) {
|
||||
case FB_DEV:
|
||||
case FB_PROD:
|
||||
case RN_DEV:
|
||||
case RN_PROD:
|
||||
return Object.assign({}, babelOpts, {
|
||||
plugins: babelOpts.plugins.concat([
|
||||
// Wrap warning() calls in a __DEV__ check so they are stripped from production.
|
||||
|
||||
@@ -144,14 +144,16 @@ function validateExplicitKey(element, parentType) {
|
||||
}
|
||||
|
||||
currentlyValidatingElement = element;
|
||||
warning(
|
||||
false,
|
||||
'Each child in an array or iterator should have a unique "key" prop.' +
|
||||
'%s%s See https://fb.me/react-warning-keys for more information.%s',
|
||||
currentComponentErrorInfo,
|
||||
childOwner,
|
||||
getStackAddendum(),
|
||||
);
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'Each child in an array or iterator should have a unique "key" prop.' +
|
||||
'%s%s See https://fb.me/react-warning-keys for more information.%s',
|
||||
currentComponentErrorInfo,
|
||||
childOwner,
|
||||
getStackAddendum(),
|
||||
);
|
||||
}
|
||||
currentlyValidatingElement = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,12 @@ var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly');
|
||||
var omittedCloseTags = require('omittedCloseTags');
|
||||
var validateDOMNesting = require('validateDOMNesting');
|
||||
var voidElementTags = require('voidElementTags');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
var warnValidStyle = require('warnValidStyle');
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
var didWarnShadyDOM = false;
|
||||
|
||||
var Flags = ReactDOMComponentFlags;
|
||||
|
||||
@@ -15,25 +15,19 @@ var EventPropagators = require('EventPropagators');
|
||||
var SyntheticEvent = require('SyntheticEvent');
|
||||
var UIManager = require('UIManager');
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var customBubblingEventTypes = UIManager.customBubblingEventTypes;
|
||||
var customDirectEventTypes = UIManager.customDirectEventTypes;
|
||||
|
||||
var allTypesByEventName = {};
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
for (var bubblingTypeName in customBubblingEventTypes) {
|
||||
allTypesByEventName[bubblingTypeName] =
|
||||
customBubblingEventTypes[bubblingTypeName];
|
||||
}
|
||||
|
||||
for (var directTypeName in customDirectEventTypes) {
|
||||
warning(
|
||||
!customBubblingEventTypes[directTypeName],
|
||||
'Event cannot be both direct and bubbling: %s',
|
||||
directTypeName,
|
||||
);
|
||||
allTypesByEventName[directTypeName] = customDirectEventTypes[directTypeName];
|
||||
for (var directTypeName in customDirectEventTypes) {
|
||||
warning(
|
||||
!customBubblingEventTypes[directTypeName],
|
||||
'Event cannot be both direct and bubbling: %s',
|
||||
directTypeName,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactNativeBridgeEventPlugin = {
|
||||
|
||||
@@ -18,7 +18,9 @@ var ReactNativeComponentTree = require('ReactNativeComponentTree');
|
||||
var ReactNativeTagHandles = require('ReactNativeTagHandles');
|
||||
var ReactGenericBatching = require('ReactGenericBatching');
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of `ReactBrowserEventEmitter` that works on the receiving side of a
|
||||
|
||||
@@ -18,7 +18,10 @@ var ReactNativeFiberRenderer = require('ReactNativeFiberRenderer');
|
||||
var {ReactCurrentOwner} = require('ReactGlobalSharedState');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
import type {Fiber} from 'ReactFiber';
|
||||
import type {ReactInstance} from 'ReactInstanceType';
|
||||
|
||||
@@ -104,13 +104,15 @@ function resetTouchRecord(touchRecord: TouchRecord, touch: Touch): void {
|
||||
|
||||
function getTouchIdentifier({identifier}: Touch): number {
|
||||
invariant(identifier != null, 'Touch object is missing identifier.');
|
||||
warning(
|
||||
identifier <= MAX_TOUCH_BANK,
|
||||
'Touch identifier %s is greater than maximum supported %s which causes ' +
|
||||
'performance issues backfilling array locations for all of the indices.',
|
||||
identifier,
|
||||
MAX_TOUCH_BANK,
|
||||
);
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
identifier <= MAX_TOUCH_BANK,
|
||||
'Touch identifier %s is greater than maximum supported %s which causes ' +
|
||||
'performance issues backfilling array locations for all of the indices.',
|
||||
identifier,
|
||||
MAX_TOUCH_BANK,
|
||||
);
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ var ReactReconciler = require('ReactReconciler');
|
||||
var instantiateReactComponent = require('instantiateReactComponent');
|
||||
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
|
||||
var traverseStackChildren = require('traverseStackChildren');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
var ReactComponentTreeHook;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ var {ReactCurrentOwner} = require('ReactGlobalSharedState');
|
||||
if (__DEV__) {
|
||||
var {ReactDebugCurrentFrame} = require('ReactGlobalSharedState');
|
||||
var ReactDebugCurrentStack = require('ReactDebugCurrentStack');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
var warningAboutMissingGetChildContext = {};
|
||||
}
|
||||
|
||||
@@ -32,7 +33,6 @@ var emptyObject = require('fbjs/lib/emptyObject');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var shallowEqual = require('fbjs/lib/shallowEqual');
|
||||
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
function StatelessComponent(Component) {}
|
||||
StatelessComponent.prototype.render = function() {
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
var ReactRef = require('ReactRef');
|
||||
var ReactInstrumentation = require('ReactInstrumentation');
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to call ReactRef.attachRefs with this composite component, split out
|
||||
@@ -187,16 +189,18 @@ var ReactReconciler = {
|
||||
updateBatchNumber,
|
||||
) {
|
||||
if (internalInstance._updateBatchNumber !== updateBatchNumber) {
|
||||
// The component's enqueued batch number should always be the current
|
||||
// batch or the following one.
|
||||
warning(
|
||||
internalInstance._updateBatchNumber == null ||
|
||||
internalInstance._updateBatchNumber === updateBatchNumber + 1,
|
||||
'performUpdateIfNecessary: Unexpected batch number (current %s, ' +
|
||||
'pending %s)',
|
||||
updateBatchNumber,
|
||||
internalInstance._updateBatchNumber,
|
||||
);
|
||||
if (__DEV__) {
|
||||
// The component's enqueued batch number should always be the current
|
||||
// batch or the following one.
|
||||
warning(
|
||||
internalInstance._updateBatchNumber == null ||
|
||||
internalInstance._updateBatchNumber === updateBatchNumber + 1,
|
||||
'performUpdateIfNecessary: Unexpected batch number (current %s, ' +
|
||||
'pending %s)',
|
||||
updateBatchNumber,
|
||||
internalInstance._updateBatchNumber,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (__DEV__) {
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
|
||||
var KeyEscapeUtils = require('KeyEscapeUtils');
|
||||
var traverseStackChildren = require('traverseStackChildren');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
var ReactComponentTreeHook;
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@ var ReactEmptyComponent = require('ReactEmptyComponent');
|
||||
var ReactHostComponent = require('ReactHostComponent');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
}
|
||||
|
||||
var nextDebugID = 1;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var KeyEscapeUtils = require('KeyEscapeUtils');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
||||
@@ -24,6 +23,7 @@ var REACT_ELEMENT_TYPE =
|
||||
0xeac7;
|
||||
|
||||
if (__DEV__) {
|
||||
var warning = require('fbjs/lib/warning');
|
||||
var {
|
||||
getCurrentStackAddendum,
|
||||
} = require('ReactGlobalSharedState').ReactComponentTreeHook;
|
||||
|
||||
Reference in New Issue
Block a user