Skip to content

Commit

Permalink
Merge pull request react-bootstrap#600 from AlexKVal/fixGlobWarning
Browse files Browse the repository at this point in the history
Fix for bug introduced by deprecation code.
  • Loading branch information
dozoisch committed May 1, 2015
2 parents 615ef25 + 92c57ef commit c508699
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/CollapsableMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const CollapsableMixin = assign({}, CollapsibleMixin, {
link
);
return this.getCollapsableDimensionValue();
},

componentDidMount() {
deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link);
}
});

deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link);

export default CollapsableMixin;
7 changes: 1 addition & 6 deletions src/CollapsableNav.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import deprecationWarning from './utils/deprecationWarning';
import CollapsibleNav from './CollapsibleNav';

let CollapsableNav = CollapsibleNav;

deprecationWarning(
'CollapsableNav',
'CollapsibleNav',
'https://github.com/react-bootstrap/react-bootstrap/issues/425#issuecomment-97110963'
);
CollapsableNav.__deprecated__ = true;

export default CollapsableNav;
11 changes: 11 additions & 0 deletions src/CollapsibleNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import BootstrapMixin from './BootstrapMixin';
import CollapsibleMixin from './CollapsibleMixin';
import classNames from 'classnames';
import domUtils from './utils/domUtils';
import deprecationWarning from './utils/deprecationWarning';

import ValidComponentChildren from './utils/ValidComponentChildren';
import createChainedFunction from './utils/createChainedFunction';
Expand Down Expand Up @@ -42,6 +43,16 @@ const CollapsibleNav = React.createClass({
return height;
},

componentDidMount() {
if (this.constructor.__deprecated__) {
deprecationWarning(
'CollapsableNav',
'CollapsibleNav',
'https://github.com/react-bootstrap/react-bootstrap/issues/425#issuecomment-97110963'
);
}
},

render() {
/*
* this.props.collapsable is set in NavBar when a eventKey is supplied.
Expand Down
14 changes: 6 additions & 8 deletions src/utils/deprecationWarning.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
function warn(message) {
if (window.console && (typeof console.warn === 'function')) {
console.warn(message);
}
}

export default function deprecationWarning(oldname, newname, link) {
if (process.env.NODE_ENV !== 'production') {
if (!window.console && (typeof console.warn !== 'function')) {
return;
}

let message = `${oldname} is deprecated. Use ${newname} instead.`;
warn(message);
console.warn(message);

if (link) {
warn(`You can read more about it here ${link}`);
console.warn(`You can read more about it here ${link}`);
}
}
}

0 comments on commit c508699

Please sign in to comment.