Skip to content

Commit c508699

Browse files
committed
Merge pull request react-bootstrap#600 from AlexKVal/fixGlobWarning
Fix for bug introduced by deprecation code.
2 parents 615ef25 + 92c57ef commit c508699

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

src/CollapsableMixin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ const CollapsableMixin = assign({}, CollapsibleMixin, {
3030
link
3131
);
3232
return this.getCollapsableDimensionValue();
33+
},
34+
35+
componentDidMount() {
36+
deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link);
3337
}
3438
});
3539

36-
deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link);
37-
3840
export default CollapsableMixin;

src/CollapsableNav.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import deprecationWarning from './utils/deprecationWarning';
21
import CollapsibleNav from './CollapsibleNav';
32

43
let CollapsableNav = CollapsibleNav;
54

6-
deprecationWarning(
7-
'CollapsableNav',
8-
'CollapsibleNav',
9-
'https://github.com/react-bootstrap/react-bootstrap/issues/425#issuecomment-97110963'
10-
);
5+
CollapsableNav.__deprecated__ = true;
116

127
export default CollapsableNav;

src/CollapsibleNav.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import BootstrapMixin from './BootstrapMixin';
33
import CollapsibleMixin from './CollapsibleMixin';
44
import classNames from 'classnames';
55
import domUtils from './utils/domUtils';
6+
import deprecationWarning from './utils/deprecationWarning';
67

78
import ValidComponentChildren from './utils/ValidComponentChildren';
89
import createChainedFunction from './utils/createChainedFunction';
@@ -42,6 +43,16 @@ const CollapsibleNav = React.createClass({
4243
return height;
4344
},
4445

46+
componentDidMount() {
47+
if (this.constructor.__deprecated__) {
48+
deprecationWarning(
49+
'CollapsableNav',
50+
'CollapsibleNav',
51+
'https://github.com/react-bootstrap/react-bootstrap/issues/425#issuecomment-97110963'
52+
);
53+
}
54+
},
55+
4556
render() {
4657
/*
4758
* this.props.collapsable is set in NavBar when a eventKey is supplied.

src/utils/deprecationWarning.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
function warn(message) {
2-
if (window.console && (typeof console.warn === 'function')) {
3-
console.warn(message);
4-
}
5-
}
6-
71
export default function deprecationWarning(oldname, newname, link) {
82
if (process.env.NODE_ENV !== 'production') {
3+
if (!window.console && (typeof console.warn !== 'function')) {
4+
return;
5+
}
6+
97
let message = `${oldname} is deprecated. Use ${newname} instead.`;
10-
warn(message);
8+
console.warn(message);
119

1210
if (link) {
13-
warn(`You can read more about it here ${link}`);
11+
console.warn(`You can read more about it here ${link}`);
1412
}
1513
}
1614
}

0 commit comments

Comments
 (0)