Skip to content

Commit

Permalink
update switchtransition for new api
Browse files Browse the repository at this point in the history
  • Loading branch information
dimensi committed Apr 18, 2019
1 parent 7f932f6 commit 43d31d4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/SwitchTransition.js
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { ENTERED, ENTERING, EXITING } from './Transition'
import TransitionGroupContext from './TransitionGroupContext';

function areChildrenDifferent(oldChildren, newChildren) {
if (oldChildren === newChildren) return false;
Expand Down Expand Up @@ -96,16 +97,6 @@ const enterRenders = {
* ```
*/
export class SwitchTransition extends React.Component {
static childContextTypes = {
transitionGroup: PropTypes.object.isRequired
};

getChildContext() {
return {
transitionGroup: { isMounting: !this.appeared }
};
}

state = {
status: ENTERED,
current: null
Expand Down Expand Up @@ -157,14 +148,23 @@ export class SwitchTransition extends React.Component {
} = this;

const data = { children, current, changeState: this.changeState, status };
let component
switch (status) {
case ENTERING:
return enterRenders[mode](data);
component = enterRenders[mode](data);
break;
case EXITING:
return leaveRenders[mode](data)
component = leaveRenders[mode](data)
break;
case ENTERED:
return current;
component = current;
}

return (
<TransitionGroupContext.Provider value={{ isMounting: !this.appeared }}>
{component}
</TransitionGroupContext.Provider>
)
}
}

Expand Down

0 comments on commit 43d31d4

Please sign in to comment.