File tree Expand file tree Collapse file tree 8 files changed +87
-15
lines changed Expand file tree Collapse file tree 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';
22import Transition from 'react-overlays/lib/Transition' ;
33import domUtils from './utils/domUtils' ;
44import CustomPropTypes from './utils/CustomPropTypes' ;
5- import deprecationWarning from './deprecationWarning' ;
5+ import deprecationWarning from './utils/ deprecationWarning' ;
66import createChainedFunction from './utils/createChainedFunction' ;
77
88let capitalize = str => str [ 0 ] . toUpperCase ( ) + str . substr ( 1 ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import Transition from 'react-overlays/lib/Transition' ;
33import CustomPropTypes from './utils/CustomPropTypes' ;
4- import deprecationWarning from './deprecationWarning' ;
4+ import deprecationWarning from './utils/ deprecationWarning' ;
55
66class Fade extends React . Component {
77 render ( ) {
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1+ import deprecationWarning from './utils/deprecationWarning' ;
12import 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+
Original file line number Diff line number Diff line change 1+ import deprecationWarning from './utils/deprecationWarning' ;
12import 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+ } ) ;
Original file line number Diff line number Diff line change 1+ import deprecationWarning from './utils/deprecationWarning' ;
12import 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+ } ) ;
Original file line number Diff line number Diff line change @@ -2,18 +2,40 @@ import warning from 'react/lib/warning';
22
33const 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+
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