From 64041669eee59236299e95735488c29a5f5d04e9 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 25 Jan 2017 12:16:25 -0800 Subject: [PATCH] The warning 'cannot calculate shadow efficiently' is not a warning anymore Reviewed By: fkgozali, yungsters Differential Revision: D4445304 fbshipit-source-id: 3a37150ae2beaf44b505dc36b575b7d44619e071 --- Libraries/ReactNative/YellowBox.js | 8 ++++++++ React/Base/RCTLog.h | 1 + React/Views/RCTView.m | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index 2c0852bab..d171da726 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/Libraries/ReactNative/YellowBox.js @@ -57,6 +57,7 @@ const _warningMap: Map = new Map(); if (__DEV__) { const {error, warn} = console; + (console: any).error = function() { error.apply(console, arguments); // Show yellow box for the `warning` module. @@ -65,8 +66,15 @@ if (__DEV__) { updateWarningMap.apply(null, arguments); } }; + (console: any).warn = function() { warn.apply(console, arguments); + + if (typeof arguments[0] === 'string' && + arguments[0].startsWith('(ADVICE)')) { + return; + } + updateWarningMap.apply(null, arguments); }; diff --git a/React/Base/RCTLog.h b/React/Base/RCTLog.h index 5cfc89c71..644adf6c9 100644 --- a/React/Base/RCTLog.h +++ b/React/Base/RCTLog.h @@ -31,6 +31,7 @@ #define RCTLog(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__) #define RCTLogTrace(...) _RCTLog(RCTLogLevelTrace, __VA_ARGS__) #define RCTLogInfo(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__) +#define RCTLogAdvice(string, ...) RCTLogWarn([@"(ADVICE) " stringByAppendingString:(NSString *)string], __VA_ARGS__) #define RCTLogWarn(...) _RCTLog(RCTLogLevelWarning, __VA_ARGS__) #define RCTLogError(...) _RCTLog(RCTLogLevelError, __VA_ARGS__) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index 0aa03e462..a832022ed 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -575,10 +575,10 @@ static void RCTUpdateShadowPathForView(RCTView *view) // Can't accurately calculate box shadow, so fall back to pixel-based shadow view.layer.shadowPath = nil; - RCTLogWarn(@"View #%@ of type %@ has a shadow set but cannot calculate " - "shadow efficiently. Consider setting a background color to " - "fix this, or apply the shadow to a more specific component.", - view.reactTag, [view class]); + RCTLogAdvice(@"View #%@ of type %@ has a shadow set but cannot calculate " + "shadow efficiently. Consider setting a background color to " + "fix this, or apply the shadow to a more specific component.", + view.reactTag, [view class]); } } }