@@ -9,60 +9,27 @@ import ReactDOM from 'react-dom'
9
9
import PropTypes from 'prop-types'
10
10
11
11
import ReactCSSTransitionGroupChild from 'react-transition-group/CSSTransitionGroupChild'
12
+ import { nameShape , transitionTimeout } from 'react-transition-group/utils/PropTypes'
13
+
12
14
13
15
const reactCSSTransitionGroupChild = React . createFactory ( ReactCSSTransitionGroupChild )
14
16
15
17
const TICK = 17
16
18
17
19
18
- function createTransitionTimeoutPropValidator ( transitionType ) {
19
- const timeoutPropName = 'transition' + transitionType + 'Timeout'
20
- const enabledPropName = 'transition' + transitionType
21
-
22
- return function ( props ) {
23
- // If the transition is enabled
24
- if ( props [ enabledPropName ] ) {
25
- // If no timeout duration is provided
26
- if ( ! props [ timeoutPropName ] ) {
27
- return new Error ( timeoutPropName + ' wasn\'t supplied to ReactCSSTransitionReplace: '
28
- + 'this can cause unreliable animations and won\'t be supported in '
29
- + 'a future version of React. See '
30
- + 'https://fb.me/react-animation-transition-group-timeout for more ' + 'information.' )
31
-
32
- // If the duration isn't a number
33
- } else if ( typeof props [ timeoutPropName ] != 'number' ) {
34
- return new Error ( timeoutPropName + ' must be a number (in milliseconds)' )
35
- }
36
- }
37
- }
38
- }
39
-
40
20
export default class ReactCSSTransitionReplace extends React . Component {
41
21
42
22
static displayName = 'ReactCSSTransitionReplace'
43
23
44
24
static propTypes = {
45
- transitionName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . shape ( {
46
- enter : PropTypes . string ,
47
- leave : PropTypes . string ,
48
- active : PropTypes . string ,
49
- height : PropTypes . string ,
50
- } ) , PropTypes . shape ( {
51
- enter : PropTypes . string ,
52
- enterActive : PropTypes . string ,
53
- leave : PropTypes . string ,
54
- leaveActive : PropTypes . string ,
55
- appear : PropTypes . string ,
56
- appearActive : PropTypes . string ,
57
- height : PropTypes . string ,
58
- } ) ] ) . isRequired ,
25
+ transitionName : nameShape . isRequired ,
59
26
60
27
transitionAppear : PropTypes . bool ,
61
28
transitionEnter : PropTypes . bool ,
62
29
transitionLeave : PropTypes . bool ,
63
- transitionAppearTimeout : createTransitionTimeoutPropValidator ( 'Appear' ) ,
64
- transitionEnterTimeout : createTransitionTimeoutPropValidator ( 'Enter' ) ,
65
- transitionLeaveTimeout : createTransitionTimeoutPropValidator ( 'Leave' ) ,
30
+ transitionAppearTimeout : transitionTimeout ( 'Appear' ) ,
31
+ transitionEnterTimeout : transitionTimeout ( 'Enter' ) ,
32
+ transitionLeaveTimeout : transitionTimeout ( 'Leave' ) ,
66
33
overflowHidden : PropTypes . bool ,
67
34
}
68
35
0 commit comments