Skip to content

Commit

Permalink
Merge pull request react-bootstrap#1022 from AlexKVal/factoriesDeprec…
Browse files Browse the repository at this point in the history
…ation

Make deprecation warnings safe
  • Loading branch information
AlexKVal committed Jul 20, 2015
2 parents 03d1cc1 + 2768061 commit 91802f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/templates/factory.index.js.template
Original file line number Diff line number Diff line change
@@ -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) { %>
Expand Down
3 changes: 2 additions & 1 deletion src/templates/factory.js.template
Original file line number Diff line number Diff line change
@@ -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 %>);
17 changes: 7 additions & 10 deletions src/utils/deprecationWarning.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 91802f6

Please sign in to comment.