From 27680616630c1e2ef1c533018d72773e8689c8f0 Mon Sep 17 00:00:00 2001 From: AlexKVal Date: Sun, 19 Jul 2015 21:55:54 +0300 Subject: [PATCH] Make deprecation warnings safe --- src/templates/factory.index.js.template | 4 +++- src/templates/factory.js.template | 3 ++- src/utils/deprecationWarning.js | 17 +++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/templates/factory.index.js.template b/src/templates/factory.index.js.template index baaeb1ef02..ba70624988 100644 --- a/src/templates/factory.index.js.template +++ b/src/templates/factory.index.js.template @@ -1,8 +1,10 @@ +import warning from 'react/lib/warning'; + <% _.forEach(components, function (component) { %> import <%= component %> from './<%= component %>'; <% }); %> -console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); +warning(false, 'Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); export default { <% _.forEach(components, function (component) { %> diff --git a/src/templates/factory.js.template b/src/templates/factory.js.template index 051dbd144e..d9a3042ba8 100644 --- a/src/templates/factory.js.template +++ b/src/templates/factory.js.template @@ -1,6 +1,7 @@ import React from 'react'; +import warning from 'react/lib/warning'; import <%= name %> from '../<%= name %>'; -console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); +warning(false, 'Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825'); export default React.createFactory(<%= name %>); diff --git a/src/utils/deprecationWarning.js b/src/utils/deprecationWarning.js index 802158410f..e92b75837d 100644 --- a/src/utils/deprecationWarning.js +++ b/src/utils/deprecationWarning.js @@ -1,14 +1,11 @@ -export default function deprecationWarning(oldname, newname, link) { - if (process.env.NODE_ENV !== 'production') { - if ((typeof console === 'undefined') || (typeof console.warn !== 'function')) { - return; - } +import warning from 'react/lib/warning'; - let message = `${oldname} is deprecated. Use ${newname} instead.`; - console.warn(message); +export default function deprecationWarning(oldname, newname, link) { + let message = `${oldname} is deprecated. Use ${newname} instead.`; - if (link) { - console.warn(`You can read more about it at ${link}`); - } + if (link) { + message += `\nYou can read more about it at ${link}`; } + + warning(false, message); }