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]); } } }