@@ -6,7 +6,6 @@ import { duration } from '../styles/transitions';
6
6
import ClickAwayListener from '../ClickAwayListener' ;
7
7
import useEventCallback from '../utils/useEventCallback' ;
8
8
import capitalize from '../utils/capitalize' ;
9
- import createChainedFunction from '../utils/createChainedFunction' ;
10
9
import Grow from '../Grow' ;
11
10
import SnackbarContent from '../SnackbarContent' ;
12
11
@@ -117,7 +116,7 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
117
116
enter : duration . enteringScreen ,
118
117
exit : duration . leavingScreen ,
119
118
} ,
120
- TransitionProps,
119
+ TransitionProps : { onEnter , onExited , ... TransitionProps } = { } ,
121
120
...other
122
121
} = props ;
123
122
@@ -185,12 +184,20 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
185
184
}
186
185
} ;
187
186
188
- const handleExited = ( ) => {
187
+ const handleExited = ( node ) => {
189
188
setExited ( true ) ;
189
+
190
+ if ( onExited ) {
191
+ onExited ( node ) ;
192
+ }
190
193
} ;
191
194
192
- const handleEnter = ( ) => {
195
+ const handleEnter = ( node , isAppearing ) => {
193
196
setExited ( false ) ;
197
+
198
+ if ( onEnter ) {
199
+ onEnter ( node , isAppearing ) ;
200
+ }
194
201
} ;
195
202
196
203
React . useEffect ( ( ) => {
@@ -212,13 +219,6 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
212
219
return null ;
213
220
}
214
221
215
- if ( TransitionProps !== undefined && TransitionProps . onEnter !== undefined ) {
216
- TransitionProps . onEnter = createChainedFunction ( handleEnter , TransitionProps . onEnter ) ;
217
- }
218
- if ( TransitionProps !== undefined && TransitionProps . onExited !== undefined ) {
219
- TransitionProps . onExited = createChainedFunction ( handleExited , TransitionProps . onExited ) ;
220
- }
221
-
222
222
return (
223
223
< ClickAwayListener onClickAway = { handleClickAway } { ...ClickAwayListenerProps } >
224
224
< div
@@ -237,6 +237,8 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
237
237
in = { open }
238
238
timeout = { transitionDuration }
239
239
direction = { vertical === 'top' ? 'down' : 'up' }
240
+ onEnter = { handleEnter }
241
+ onExited = { handleExited }
240
242
{ ...TransitionProps }
241
243
>
242
244
{ children || < SnackbarContent message = { message } action = { action } { ...ContentProps } /> }
0 commit comments