check that console exists before warning

Console is undefined in earlier versions of IE when it is not open. This causes an uncaught exception, and breaks applications in these versions of IE when attempting to warn when the  console is closed.
Admittedly, console will usually be open when testing in development, but still React should not break the application when it is not.
This commit is contained in:
Darcy 2015-03-04 10:43:20 -05:00
parent fa8961118a
commit 6b593083ed
1 changed files with 3 additions and 1 deletions

View File

@ -45,7 +45,9 @@ if (__DEV__) {
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
console.warn(message);
if (typeof console !== 'undefined') {
console.warn(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack