diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index e36681458d716e..88e786ab0d7d5b 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/Libraries/ReactNative/YellowBox.js @@ -106,17 +106,22 @@ function sprintf(format, ...args) { return format.replace(/%s/g, match => args[index++]); } -function updateWarningMap(format, ...args): void { +function updateWarningMap(...args): void { if (console.disableYellowBox) { return; } - format = String(format); - const argCount = (format.match(/%s/g) || []).length; - const warning = [ - sprintf(format, ...args.slice(0, argCount)), - ...args.slice(argCount).map(stringifySafe), - ].join(' '); + let warning; + if (typeof args[0] === 'string') { + const [format, ...formatArgs] = args; + const argCount = (format.match(/%s/g) || []).length; + warning = [ + sprintf(format, ...formatArgs.slice(0, argCount).map(stringifySafe)), + ...formatArgs.slice(argCount).map(stringifySafe), + ].join(' '); + } else { + warning = args.map(stringifySafe).join(' '); + } if (warning.startsWith('(ADVICE)')) { return;