RN: Ignore StyleSheetValidation if Profiling

Summary: Removes `StyleSheetValidation` when profiling because it creates noise and looks pretty expensive.

Reviewed By: TheSavior

Differential Revision: D9890117

fbshipit-source-id: cc1b8d4e4bc40be2333f09321892317bc841aae0
This commit is contained in:
Tim Yung 2018-09-19 16:17:48 -07:00 committed by Facebook Github Bot
parent 24679cd32b
commit d7b34dd38d
1 changed files with 10 additions and 5 deletions

View File

@ -24,7 +24,7 @@ const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
class StyleSheetValidation {
static validateStyleProp(prop: string, style: Object, caller: string) {
if (!__DEV__) {
if (!__DEV__ || global.__RCTProfileIsProfiling) {
return;
}
if (allStylePropTypes[prop] === undefined) {
@ -48,7 +48,7 @@ class StyleSheetValidation {
}
static validateStyle(name: string, styles: Object) {
if (!__DEV__) {
if (!__DEV__ || global.__RCTProfileIsProfiling) {
return;
}
for (const prop in styles[name]) {
@ -61,6 +61,9 @@ class StyleSheetValidation {
}
static addValidStylePropTypes(stylePropTypes) {
if (!__DEV__ || global.__RCTProfileIsProfiling) {
return;
}
for (const key in stylePropTypes) {
allStylePropTypes[key] = stylePropTypes[key];
}
@ -81,8 +84,10 @@ const styleError = function(message1, style, caller?, message2?) {
const allStylePropTypes = {};
StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes);
if (__DEV__ && !global.__RCTProfileIsProfiling) {
StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes);
}
module.exports = StyleSheetValidation;