@@ -16,13 +16,14 @@ import memoize from '../utils/memoize';
1616type Props = {
1717 focused : boolean ;
1818 stale : boolean ;
19+ closing ?: boolean ;
1920 next ?: Animated . Node < number > ;
2021 current : Animated . Value < number > ;
2122 layout : { width : number ; height : number } ;
2223 direction : 'horizontal' | 'vertical' ;
2324 onOpen ?: ( ) => void ;
2425 onClose ?: ( ) => void ;
25- children : ( props : { close : ( ) => void } ) => React . ReactNode ;
26+ children : React . ReactNode ;
2627 animationsEnabled : boolean ;
2728 gesturesEnabled : boolean ;
2829 transitionSpec : {
@@ -79,7 +80,7 @@ export default class Card extends React.Component<Props> {
7980 } ;
8081
8182 componentDidUpdate ( prevProps : Props ) {
82- const { layout, direction, animationsEnabled } = this . props ;
83+ const { layout, direction, closing , animationsEnabled } = this . props ;
8384 const { width, height } = layout ;
8485
8586 if (
@@ -103,6 +104,10 @@ export default class Card extends React.Component<Props> {
103104 direction === 'vertical' ? DIRECTION_VERTICAL : DIRECTION_HORIZONTAL
104105 ) ;
105106 }
107+
108+ if ( closing !== prevProps . closing ) {
109+ this . isClosing . setValue ( closing ? TRUE : FALSE ) ;
110+ }
106111 }
107112
108113 private isVisible = new Value < Binary > ( TRUE ) ;
@@ -321,8 +326,6 @@ export default class Card extends React.Component<Props> {
321326 } ,
322327 ] ) ;
323328
324- private handleClose = ( ) => this . isClosing . setValue ( TRUE ) ;
325-
326329 // We need to ensure that this style doesn't change unless absolutely needs to
327330 // Changing it too often will result in huge frame drops due to detaching and attaching
328331 // Changing it during an animations can result in unexpected results
@@ -388,9 +391,7 @@ export default class Card extends React.Component<Props> {
388391 active = { stale ? 0 : 1 }
389392 style = { styles . screen }
390393 >
391- { children ( {
392- close : this . handleClose ,
393- } ) }
394+ { children }
394395 </ Screen >
395396 </ Animated . View >
396397 </ PanGestureHandler >
0 commit comments