Skip to content

Commit 91802f6

Browse files
committed
Merge pull request react-bootstrap#1022 from AlexKVal/factoriesDeprecation
Make deprecation warnings safe
2 parents 03d1cc1 + 2768061 commit 91802f6

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/templates/factory.index.js.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import warning from 'react/lib/warning';
2+
13
<% _.forEach(components, function (component) { %>
24
import <%= component %> from './<%= component %>';
35
<% }); %>
46

5-
console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825');
7+
warning(false, 'Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825');
68

79
export default {
810
<% _.forEach(components, function (component) { %>

src/templates/factory.js.template

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2+
import warning from 'react/lib/warning';
23
import <%= name %> from '../<%= name %>';
34

4-
console.warn('Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825');
5+
warning(false, 'Support for factories will be removed in v0.25, for details see https://github.com/react-bootstrap/react-bootstrap/issues/825');
56

67
export default React.createFactory(<%= name %>);

src/utils/deprecationWarning.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
export default function deprecationWarning(oldname, newname, link) {
2-
if (process.env.NODE_ENV !== 'production') {
3-
if ((typeof console === 'undefined') || (typeof console.warn !== 'function')) {
4-
return;
5-
}
1+
import warning from 'react/lib/warning';
62

7-
let message = `${oldname} is deprecated. Use ${newname} instead.`;
8-
console.warn(message);
3+
export default function deprecationWarning(oldname, newname, link) {
4+
let message = `${oldname} is deprecated. Use ${newname} instead.`;
95

10-
if (link) {
11-
console.warn(`You can read more about it at ${link}`);
12-
}
6+
if (link) {
7+
message += `\nYou can read more about it at ${link}`;
138
}
9+
10+
warning(false, message);
1411
}

0 commit comments

Comments
 (0)