Skip to content

Commit 43d31d4

Browse files
committed
update switchtransition for new api
1 parent 7f932f6 commit 43d31d4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/SwitchTransition.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { ENTERED, ENTERING, EXITING } from './Transition'
4+
import TransitionGroupContext from './TransitionGroupContext';
45

56
function areChildrenDifferent(oldChildren, newChildren) {
67
if (oldChildren === newChildren) return false;
@@ -96,16 +97,6 @@ const enterRenders = {
9697
* ```
9798
*/
9899
export class SwitchTransition extends React.Component {
99-
static childContextTypes = {
100-
transitionGroup: PropTypes.object.isRequired
101-
};
102-
103-
getChildContext() {
104-
return {
105-
transitionGroup: { isMounting: !this.appeared }
106-
};
107-
}
108-
109100
state = {
110101
status: ENTERED,
111102
current: null
@@ -157,14 +148,23 @@ export class SwitchTransition extends React.Component {
157148
} = this;
158149

159150
const data = { children, current, changeState: this.changeState, status };
151+
let component
160152
switch (status) {
161153
case ENTERING:
162-
return enterRenders[mode](data);
154+
component = enterRenders[mode](data);
155+
break;
163156
case EXITING:
164-
return leaveRenders[mode](data)
157+
component = leaveRenders[mode](data)
158+
break;
165159
case ENTERED:
166-
return current;
160+
component = current;
167161
}
162+
163+
return (
164+
<TransitionGroupContext.Provider value={{ isMounting: !this.appeared }}>
165+
{component}
166+
</TransitionGroupContext.Provider>
167+
)
168168
}
169169
}
170170

0 commit comments

Comments
 (0)