File tree 8 files changed +87
-15
lines changed
8 files changed +87
-15
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from 'react';
2
2
import Transition from 'react-overlays/lib/Transition' ;
3
3
import domUtils from './utils/domUtils' ;
4
4
import CustomPropTypes from './utils/CustomPropTypes' ;
5
- import deprecationWarning from './deprecationWarning' ;
5
+ import deprecationWarning from './utils/ deprecationWarning' ;
6
6
import createChainedFunction from './utils/createChainedFunction' ;
7
7
8
8
let capitalize = str => str [ 0 ] . toUpperCase ( ) + str . substr ( 1 ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import Transition from 'react-overlays/lib/Transition' ;
3
3
import CustomPropTypes from './utils/CustomPropTypes' ;
4
- import deprecationWarning from './deprecationWarning' ;
4
+ import deprecationWarning from './utils/ deprecationWarning' ;
5
5
6
6
class Fade extends React . Component {
7
7
render ( ) {
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ const Modal = React.createClass({
177
177
transitionAppear
178
178
unmountOnExit
179
179
in = { show }
180
- duration = { Modal . TRANSITION_DURATION }
180
+ timeout = { Modal . TRANSITION_DURATION }
181
181
onExit = { onExit }
182
182
onExiting = { onExiting }
183
183
onExited = { this . handleHidden }
@@ -231,7 +231,7 @@ const Modal = React.createClass({
231
231
< div
232
232
ref = 'modal' >
233
233
{ animation
234
- ? < Fade transitionAppear in = { this . props . show } duration = { duration } > { backdrop } </ Fade >
234
+ ? < Fade transitionAppear in = { this . props . show } timeout = { duration } > { backdrop } </ Fade >
235
235
: backdrop
236
236
}
237
237
{ modal }
Original file line number Diff line number Diff line change
1
+ import deprecationWarning from './utils/deprecationWarning' ;
1
2
import Portal from 'react-overlays/lib/Portal' ;
2
3
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
+
Original file line number Diff line number Diff line change
1
+ import deprecationWarning from './utils/deprecationWarning' ;
1
2
import Position from 'react-overlays/lib/Position' ;
2
3
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
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import deprecationWarning from './utils/deprecationWarning' ;
1
2
import Transition from 'react-overlays/lib/Transition' ;
2
3
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
+ } ) ;
Original file line number Diff line number Diff line change @@ -2,18 +2,40 @@ import warning from 'react/lib/warning';
2
2
3
3
const warned = { } ;
4
4
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 ;
9
10
}
11
+ else {
12
+ message = `${ oldname } is deprecated. Use ${ newname } instead.` ;
10
13
11
- let message = `${ oldname } is deprecated. Use ${ newname } instead.` ;
14
+ if ( link ) {
15
+ message += `\nYou can read more about it at ${ link } ` ;
16
+ }
17
+ }
12
18
13
- if ( link ) {
14
- message += `\nYou can read more about it at ${ link } ` ;
19
+ if ( warned [ message ] ) {
20
+ return ;
15
21
}
16
22
17
23
warning ( false , message ) ;
18
- warned [ warnKey ] = true ;
24
+ warned [ message ] = true ;
19
25
}
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
+
Original file line number Diff line number Diff line change
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 ( / P o s i t i o n c o m p o n e n t i s d e p r e c a t e d / ) ;
15
+ } ) ;
16
+
17
+ it ( 'should warn about Transition' , ( ) => {
18
+ ReactTestUtils . renderIntoDocument ( < Transition > < div /> </ Transition > ) ;
19
+
20
+ shouldWarn ( / T r a n s i t i o n c o m p o n e n t i s d e p r e c a t e d / ) ;
21
+ } ) ;
22
+
23
+ it ( 'should warn about Portal' , ( ) => {
24
+ ReactTestUtils . renderIntoDocument ( < Portal > < div /> </ Portal > ) ;
25
+
26
+ shouldWarn ( / P o r t a l c o m p o n e n t i s d e p r e c a t e d / ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments