Skip to content

Commit 628d586

Browse files
committedAug 17, 2015
[changed] deprecated Position, Transition, Portal
1 parent 03a6a61 commit 628d586

File tree

8 files changed

+87
-15
lines changed

8 files changed

+87
-15
lines changed
 

‎src/Collapse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import Transition from 'react-overlays/lib/Transition';
33
import domUtils from './utils/domUtils';
44
import CustomPropTypes from './utils/CustomPropTypes';
5-
import deprecationWarning from './deprecationWarning';
5+
import deprecationWarning from './utils/deprecationWarning';
66
import createChainedFunction from './utils/createChainedFunction';
77

88
let capitalize = str => str[0].toUpperCase() + str.substr(1);

‎src/Fade.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import Transition from 'react-overlays/lib/Transition';
33
import CustomPropTypes from './utils/CustomPropTypes';
4-
import deprecationWarning from './deprecationWarning';
4+
import deprecationWarning from './utils/deprecationWarning';
55

66
class Fade extends React.Component {
77
render() {

‎src/Modal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const Modal = React.createClass({
177177
transitionAppear
178178
unmountOnExit
179179
in={show}
180-
duration={Modal.TRANSITION_DURATION}
180+
timeout={Modal.TRANSITION_DURATION}
181181
onExit={onExit}
182182
onExiting={onExiting}
183183
onExited={this.handleHidden}
@@ -231,7 +231,7 @@ const Modal = React.createClass({
231231
<div
232232
ref='modal'>
233233
{ animation
234-
? <Fade transitionAppear in={this.props.show} duration={duration}>{backdrop}</Fade>
234+
? <Fade transitionAppear in={this.props.show} timeout={duration}>{backdrop}</Fade>
235235
: backdrop
236236
}
237237
{modal}

‎src/Portal.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import deprecationWarning from './utils/deprecationWarning';
12
import Portal from 'react-overlays/lib/Portal';
23

3-
export default Portal;
4+
export default deprecationWarning.wrapper(Portal, {
5+
message:
6+
'The Portal component is deprecated in react-bootstrap. It has been moved to a more generic library: react-overlays. ' +
7+
'You can read more at: ' +
8+
'http://react-bootstrap.github.io/react-overlays/examples/#portal and ' +
9+
'https://github.com/react-bootstrap/react-bootstrap/issues/1084'
10+
});
11+

‎src/Position.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import deprecationWarning from './utils/deprecationWarning';
12
import Position from 'react-overlays/lib/Position';
23

3-
export default Position;
4+
export default deprecationWarning.wrapper(Position, {
5+
message:
6+
'The Position component is deprecated in react-bootstrap. It has been moved to a more generic library: react-overlays. ' +
7+
'You can read more at: ' +
8+
'http://react-bootstrap.github.io/react-overlays/examples/#position and ' +
9+
'https://github.com/react-bootstrap/react-bootstrap/issues/1084'
10+
});

‎src/Transition.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import deprecationWarning from './utils/deprecationWarning';
12
import Transition from 'react-overlays/lib/Transition';
23

3-
export default Transition;
4+
export default deprecationWarning.wrapper(Transition, {
5+
message:
6+
'The Transition component is deprecated in react-bootstrap. It has been moved to a more generic library: react-overlays. ' +
7+
'You can read more at: ' +
8+
'http://react-bootstrap.github.io/react-overlays/examples/#transition and ' +
9+
'https://github.com/react-bootstrap/react-bootstrap/issues/1084'
10+
});

‎src/utils/deprecationWarning.js

+30-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,40 @@ import warning from 'react/lib/warning';
22

33
const warned = {};
44

5-
export default function deprecationWarning(oldname, newname, link) {
6-
const warnKey = `${oldname}\n${newname}`;
7-
if (warned[warnKey]) {
8-
return;
5+
function deprecationWarning(oldname, newname, link) {
6+
let message;
7+
8+
if (typeof oldname === 'object'){
9+
message = oldname.message;
910
}
11+
else {
12+
message = `${oldname} is deprecated. Use ${newname} instead.`;
1013

11-
let message = `${oldname} is deprecated. Use ${newname} instead.`;
14+
if (link) {
15+
message += `\nYou can read more about it at ${link}`;
16+
}
17+
}
1218

13-
if (link) {
14-
message += `\nYou can read more about it at ${link}`;
19+
if (warned[message]) {
20+
return;
1521
}
1622

1723
warning(false, message);
18-
warned[warnKey] = true;
24+
warned[message] = true;
1925
}
26+
27+
28+
deprecationWarning.wrapper = function(Component, ...args){
29+
return class DeprecatedComponent extends Component {
30+
componentWillMount(...methodArgs){
31+
deprecationWarning(...args);
32+
33+
if (super.componentWillMount) {
34+
super.componentWillMount(...methodArgs);
35+
}
36+
}
37+
};
38+
};
39+
40+
export default deprecationWarning;
41+

‎test/OverlayDeprecationSpec.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import ReactTestUtils from 'react/lib/ReactTestUtils';
3+
import Position from '../src/Position';
4+
import Transition from '../src/Transition';
5+
import Portal from '../src/Portal';
6+
7+
import { shouldWarn } from './helpers';
8+
9+
describe('Components moved to react-overlays', ()=>{
10+
11+
it('should warn about Position', ()=>{
12+
ReactTestUtils.renderIntoDocument(<Position><div/></Position>);
13+
14+
shouldWarn(/Position component is deprecated/);
15+
});
16+
17+
it('should warn about Transition', ()=>{
18+
ReactTestUtils.renderIntoDocument(<Transition><div/></Transition>);
19+
20+
shouldWarn(/Transition component is deprecated/);
21+
});
22+
23+
it('should warn about Portal', ()=>{
24+
ReactTestUtils.renderIntoDocument(<Portal><div/></Portal>);
25+
26+
shouldWarn(/Portal component is deprecated/);
27+
});
28+
});

0 commit comments

Comments
 (0)
Please sign in to comment.