| 375 | } |
| 376 | |
| 377 | function printWarning(level, format, args) { |
| 378 | // When changing this logic, you might want to also |
| 379 | // update consoleWithStackDev.www.js as well. |
| 380 | { |
| 381 | var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; |
| 382 | |
| 383 | if (!hasExistingStack) { |
| 384 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; |
| 385 | var stack = ReactDebugCurrentFrame.getStackAddendum(); |
| 386 | |
| 387 | if (stack !== '') { |
| 388 | format += '%s'; |
| 389 | args = args.concat([stack]); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | var argsWithFormat = args.map(function (item) { |
| 394 | return '' + item; |
| 395 | }); // Careful: RN currently depends on this prefix |
| 396 | |
| 397 | argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it |
| 398 | // breaks IE9: https://github.com/facebook/react/issues/13610 |
| 399 | // eslint-disable-next-line react-internal/no-production-logging |
| 400 | |
| 401 | Function.prototype.apply.call(console[level], console, argsWithFormat); |
| 402 | |
| 403 | try { |
| 404 | // --- Welcome to debugging React --- |
| 405 | // This error was thrown as a convenience so that you can use this stack |
| 406 | // to find the callsite that caused this warning to fire. |
| 407 | var argIndex = 0; |
| 408 | var message = 'Warning: ' + format.replace(/%s/g, function () { |
| 409 | return args[argIndex++]; |
| 410 | }); |
| 411 | throw new Error(message); |
| 412 | } catch (x) {} |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | var didWarnStateUpdateForUnmountedComponent = {}; |
| 417 | |