Skip to content

Commit 5376f88

Browse files
committed
Use deprecated prop type where applicable
1 parent 6a24a67 commit 5376f88

4 files changed

Lines changed: 14 additions & 32 deletions

File tree

src/Collapse.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import css from 'dom-helpers/style';
12
import React from 'react';
23
import Transition from 'react-overlays/lib/Transition';
3-
import css from 'dom-helpers/style';
4-
import all from 'react-prop-types/lib/all';
5-
import deprecationWarning from './utils/deprecationWarning';
4+
import deprecated from 'react-prop-types/lib/deprecated';
5+
66
import createChainedFunction from './utils/createChainedFunction';
77

88
let capitalize = str => str[0].toUpperCase() + str.substr(1);
@@ -145,15 +145,7 @@ Collapse.propTypes = {
145145
* duration
146146
* @private
147147
*/
148-
duration: all(
149-
React.PropTypes.number,
150-
(props)=> {
151-
if (props.duration != null) {
152-
deprecationWarning('Collapse `duration`', 'the `timeout` prop');
153-
}
154-
return null;
155-
}
156-
),
148+
duration: deprecated(React.PropTypes.number, 'Use `timeout`.'),
157149

158150
/**
159151
* Callback fired before the component expands

src/Fade.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import Transition from 'react-overlays/lib/Transition';
3-
import all from 'react-prop-types/lib/all';
4-
import deprecationWarning from './utils/deprecationWarning';
3+
import deprecated from 'react-prop-types/lib/deprecated';
54

65
class Fade extends React.Component {
76
render() {
@@ -51,15 +50,7 @@ Fade.propTypes = {
5150
* duration
5251
* @private
5352
*/
54-
duration: all(
55-
React.PropTypes.number,
56-
(props)=> {
57-
if (props.duration != null) {
58-
deprecationWarning('Fade `duration`', 'the `timeout` prop');
59-
}
60-
return null;
61-
}
62-
),
53+
duration: deprecated(React.PropTypes.number, 'Use `timeout`.'),
6354

6455
/**
6556
* Callback fired before the component fades in

src/Navbar.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import classNames from 'classnames';
22
import React from 'react';
3+
import deprecated from 'react-prop-types/lib/deprecated';
34
import elementType from 'react-prop-types/lib/elementType';
45

56
import BootstrapMixin from './BootstrapMixin';
67
import Grid from './Grid';
78
import NavBrand from './NavBrand';
89

910
import createChainedFunction from './utils/createChainedFunction';
10-
import deprecationWarning from './utils/deprecationWarning';
1111
import ValidComponentChildren from './utils/ValidComponentChildren';
1212

1313
const Navbar = React.createClass({
@@ -24,7 +24,7 @@ const Navbar = React.createClass({
2424
* You can use a custom element for this component
2525
*/
2626
componentClass: elementType,
27-
brand: React.PropTypes.node,
27+
brand: deprecated(React.PropTypes.node, 'Use the `NavBrand` component.'),
2828
toggleButton: React.PropTypes.node,
2929
toggleNavKey: React.PropTypes.oneOfType([
3030
React.PropTypes.string,
@@ -61,13 +61,6 @@ const Navbar = React.createClass({
6161
return !this._isChanging;
6262
},
6363

64-
componentWillMount() {
65-
// TODO: Use the `deprecated` PropType once we're on React 0.14.
66-
if (this.props.brand) {
67-
deprecationWarning('Navbar brand attribute', 'NavBrand Component');
68-
}
69-
},
70-
7164
handleToggle() {
7265
if (this.props.onToggle) {
7366
this._isChanging = true;

test/NavbarSpec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ describe('Navbar', () => {
9090
assert.ok(brand);
9191
assert.equal(brand.nodeName, 'SPAN');
9292
assert.equal(brand.innerText, 'Brand');
93+
94+
shouldWarn('deprecated');
9395
});
9496

9597
it('Should add span element with navbar-brand class using NavBrand Component', () => {
@@ -120,6 +122,8 @@ describe('Navbar', () => {
120122
assert.ok(brand);
121123
assert.equal(brand.nodeName, 'A');
122124
assert.equal(brand.innerText, 'Brand');
125+
126+
shouldWarn('deprecated');
123127
});
124128

125129
it('Should add link element with navbar-brand class using NavBrand Component', () => {
@@ -148,6 +152,8 @@ describe('Navbar', () => {
148152
assert.equal(brands.length, 1);
149153
assert.equal(brands[0].nodeName, 'SPAN');
150154
assert.equal(brands[0].innerText, 'Brand');
155+
156+
shouldWarn('deprecated');
151157
});
152158

153159
it('Should pass navbar prop to navs', () => {

0 commit comments

Comments
 (0)