@@ -13,17 +13,22 @@ import * as React from 'react'
13
13
import { ThemeContext } from 'react-fela'
14
14
import { Transition } from 'react-transition-group'
15
15
16
- import { childrenExist , StyledComponentProps , commonPropTypes } from '../../utils'
16
+ import {
17
+ childrenExist ,
18
+ StyledComponentProps ,
19
+ commonPropTypes ,
20
+ ChildrenComponentProps ,
21
+ } from '../../utils'
17
22
import { ComponentEventHandler , ProviderContextPrepared } from '../../types'
18
23
19
24
export type AnimationChildrenProp = ( props : { classes : string } ) => React . ReactNode
20
25
21
- export interface AnimationProps extends StyledComponentProps {
26
+ export interface AnimationProps
27
+ extends StyledComponentProps ,
28
+ ChildrenComponentProps < AnimationChildrenProp | React . ReactChild > {
22
29
/** Additional CSS class name(s) to apply. */
23
30
className ?: string
24
31
25
- children : AnimationChildrenProp | React . ReactChild
26
-
27
32
/** The name for the animation that should be applied, defined in the theme. */
28
33
name ?: string
29
34
@@ -216,6 +221,12 @@ const Animation: React.FC<AnimationProps> & {
216
221
playState ,
217
222
timingFunction ,
218
223
] )
224
+
225
+ if ( _ . isNil ( children ) ) {
226
+ setEnd ( )
227
+ return null
228
+ }
229
+
219
230
const unhandledProps = getUnhandledProps ( Animation . handledProps , props )
220
231
221
232
const isChildrenFunction = typeof children === 'function'
@@ -238,7 +249,7 @@ const Animation: React.FC<AnimationProps> & {
238
249
onExiting = { handleAnimationEvent ( 'onExiting' ) }
239
250
onExited = { handleAnimationEvent ( 'onExited' ) }
240
251
{ ...unhandledProps }
241
- className = { ! isChildrenFunction ? cx ( classes . root , ( child as any ) . props . className ) : '' }
252
+ className = { ! isChildrenFunction ? cx ( classes . root , ( child as any ) ? .props ? .className ) : '' }
242
253
>
243
254
{ isChildrenFunction
244
255
? ( ) => ( children as AnimationChildrenProp ) ( { classes : classes . root } )
0 commit comments