diff --git a/src/CollapsableMixin.js b/src/CollapsableMixin.js index 1aae543000..30ac3e0083 100644 --- a/src/CollapsableMixin.js +++ b/src/CollapsableMixin.js @@ -30,9 +30,11 @@ const CollapsableMixin = assign({}, CollapsibleMixin, { link ); return this.getCollapsableDimensionValue(); + }, + + componentDidMount() { + deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link); } }); -deprecationWarning('CollapsableMixin', 'CollapsibleMixin', link); - export default CollapsableMixin; diff --git a/src/CollapsableNav.js b/src/CollapsableNav.js index cc211684f3..07a7a2f928 100644 --- a/src/CollapsableNav.js +++ b/src/CollapsableNav.js @@ -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; diff --git a/src/CollapsibleNav.js b/src/CollapsibleNav.js index e8af629387..879c74ccd0 100644 --- a/src/CollapsibleNav.js +++ b/src/CollapsibleNav.js @@ -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'; @@ -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. diff --git a/src/utils/deprecationWarning.js b/src/utils/deprecationWarning.js index 3cc0a98e4b..6b15bbc1d4 100644 --- a/src/utils/deprecationWarning.js +++ b/src/utils/deprecationWarning.js @@ -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}`); } } }