File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import { ENTERED , ENTERING , EXITING } from './Transition'
4+ import TransitionGroupContext from './TransitionGroupContext' ;
45
56function areChildrenDifferent ( oldChildren , newChildren ) {
67 if ( oldChildren === newChildren ) return false ;
@@ -96,16 +97,6 @@ const enterRenders = {
9697 * ```
9798 */
9899export 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
You can’t perform that action at this time.
0 commit comments