MCPcopy Index your code
hub / github.com/microsoft/SandDance / printWarning

Function printWarning

docs/external/js/react-dom.development.js:58–95  ·  view source on GitHub ↗
(level, format, args)

Source from the content-addressed store, hash-verified

56 }
57
58 function printWarning(level, format, args) {
59 // When changing this logic, you might want to also
60 // update consoleWithStackDev.www.js as well.
61 {
62 var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
63
64 if (!hasExistingStack) {
65 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
66 var stack = ReactDebugCurrentFrame.getStackAddendum();
67
68 if (stack !== '') {
69 format += '%s';
70 args = args.concat([stack]);
71 }
72 }
73
74 var argsWithFormat = args.map(function (item) {
75 return '' + item;
76 }); // Careful: RN currently depends on this prefix
77
78 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
79 // breaks IE9: https://github.com/facebook/react/issues/13610
80 // eslint-disable-next-line react-internal/no-production-logging
81
82 Function.prototype.apply.call(console[level], console, argsWithFormat);
83
84 try {
85 // --- Welcome to debugging React ---
86 // This error was thrown as a convenience so that you can use this stack
87 // to find the callsite that caused this warning to fire.
88 var argIndex = 0;
89 var message = 'Warning: ' + format.replace(/%s/g, function () {
90 return args[argIndex++];
91 });
92 throw new Error(message);
93 } catch (x) {}
94 }
95 }
96
97 if (!React) {
98 {

Callers 2

warnFunction · 0.70
errorFunction · 0.70

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected