Skip to content

Commit 3414d2f

Browse files
committed
[Snackbar] remove transition onX props
1 parent f434177 commit 3414d2f

File tree

5 files changed

+32
-69
lines changed

5 files changed

+32
-69
lines changed

docs/pages/api-docs/snackbar.md

-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ The `MuiSnackbar` name can be used for providing [default props](/customization/
3939
| <span class="prop-name">key</span> | <span class="prop-type">any</span> | | When displaying multiple consecutive Snackbars from a parent rendering a single &lt;Snackbar/>, add the key prop to ensure independent treatment of each message. e.g. &lt;Snackbar key={message} />, otherwise, the message may update-in-place and features such as autoHideDuration may be canceled. |
4040
| <span class="prop-name">message</span> | <span class="prop-type">node</span> | | The message to display. |
4141
| <span class="prop-name">onClose</span> | <span class="prop-type">func</span> | | Callback fired when the component requests to be closed. Typically `onClose` is used to set state in the parent component, which is used to control the `Snackbar` `open` prop. The `reason` parameter can optionally be used to control the response to `onClose`, for example ignoring `clickaway`.<br><br>**Signature:**<br>`function(event: object, reason: string) => void`<br>*event:* The event source of the callback.<br>*reason:* Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`. |
42-
| <span class="prop-name">onEnter</span> | <span class="prop-type">func</span> | | Callback fired before the transition is entering. |
43-
| <span class="prop-name">onEntered</span> | <span class="prop-type">func</span> | | Callback fired when the transition has entered. |
44-
| <span class="prop-name">onEntering</span> | <span class="prop-type">func</span> | | Callback fired when the transition is entering. |
45-
| <span class="prop-name">onExit</span> | <span class="prop-type">func</span> | | Callback fired before the transition is exiting. |
46-
| <span class="prop-name">onExited</span> | <span class="prop-type">func</span> | | Callback fired when the transition has exited. |
47-
| <span class="prop-name">onExiting</span> | <span class="prop-type">func</span> | | Callback fired when the transition is exiting. |
4842
| <span class="prop-name">open</span> | <span class="prop-type">bool</span> | | If `true`, `Snackbar` is open. |
4943
| <span class="prop-name">resumeHideDuration</span> | <span class="prop-type">number</span> | | The number of milliseconds to wait before dismissing after user interaction. If `autoHideDuration` prop isn't specified, it does nothing. If `autoHideDuration` prop is specified but `resumeHideDuration` isn't, we default to `autoHideDuration / 2` ms. |
5044
| <span class="prop-name">TransitionComponent</span> | <span class="prop-type">elementType</span> | <span class="prop-default">Grow</span> | The component used for the transition. [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component. |

docs/src/pages/guides/migration-v4/migration-v4.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,36 @@ This change affects almost all components where you're using the `component` pro
256256
### Snackbar
257257

258258
- The notification now displays at the bottom left on large screens.
259-
It better matches the behavior of Gmail, Google Keep, material.io, etc.
259+
This better matches the behavior of Gmail, Google Keep, material.io, etc.
260260
You can restore the previous behavior with:
261261

262262
```diff
263263
-<Snackbar />
264264
+<Snackbar anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} />
265265
```
266266

267+
- The onE\* transition props were removed. Use TransitionProps instead.
268+
269+
````diff
270+
<Snackbar
271+
- onEnter={onEnter}
272+
- onEntered={onEntered},
273+
- onEntering={onEntered},
274+
- onExit={onEntered},
275+
- onExited={onEntered},
276+
- onExiting={onEntered}
277+
/>
278+
<Snackbar
279+
+ TransitionProps={{
280+
+ onEnter,
281+
+ onEntered,
282+
+ onEntering,
283+
+ onExit,
284+
+ onExited,
285+
+ onExiting,
286+
+ }}
287+
/>
288+
267289
### Skeleton
268290

269291
- Rename `circle` to `circular` and `rect` to `rectangular` for consistency. The possible values should be adjectives, not nouns:
@@ -275,7 +297,7 @@ This change affects almost all components where you're using the `component` pro
275297
+<Skeleton variant="circular" />
276298
+<Skeleton variant="rectangular" />
277299
-<Skeleton classes={{ circular: 'custom-circle-classname', rectangular: 'custom-rect-classname', }} />
278-
```
300+
````
279301

280302
### TablePagination
281303

packages/material-ui/src/Snackbar/Snackbar.d.ts

-24
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,6 @@ export interface SnackbarProps
7171
* @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`.
7272
*/
7373
onClose?: (event: React.SyntheticEvent<any>, reason: SnackbarCloseReason) => void;
74-
/**
75-
* Callback fired before the transition is entering.
76-
*/
77-
onEnter?: TransitionHandlerProps['onEnter'];
78-
/**
79-
* Callback fired when the transition has entered.
80-
*/
81-
onEntered?: TransitionHandlerProps['onEntered'];
82-
/**
83-
* Callback fired when the transition is entering.
84-
*/
85-
onEntering?: TransitionHandlerProps['onEntering'];
86-
/**
87-
* Callback fired before the transition is exiting.
88-
*/
89-
onExit?: TransitionHandlerProps['onExit'];
90-
/**
91-
* Callback fired when the transition has exited.
92-
*/
93-
onExited?: TransitionHandlerProps['onExited'];
94-
/**
95-
* Callback fired when the transition is exiting.
96-
*/
97-
onExiting?: TransitionHandlerProps['onExiting'];
9874
/**
9975
* If `true`, `Snackbar` is open.
10076
*/

packages/material-ui/src/Snackbar/Snackbar.js

+7-36
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
108108
disableWindowBlurListener = false,
109109
message,
110110
onClose,
111-
onEnter,
112-
onEntered,
113-
onEntering,
114-
onExit,
115-
onExited,
116-
onExiting,
117111
onMouseEnter,
118112
onMouseLeave,
119113
open,
@@ -218,6 +212,13 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
218212
return null;
219213
}
220214

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+
221222
return (
222223
<ClickAwayListener onClickAway={handleClickAway} {...ClickAwayListenerProps}>
223224
<div
@@ -234,12 +235,6 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) {
234235
<TransitionComponent
235236
appear
236237
in={open}
237-
onEnter={createChainedFunction(handleEnter, onEnter)}
238-
onEntered={onEntered}
239-
onEntering={onEntering}
240-
onExit={onExit}
241-
onExited={createChainedFunction(handleExited, onExited)}
242-
onExiting={onExiting}
243238
timeout={transitionDuration}
244239
direction={vertical === 'top' ? 'down' : 'up'}
245240
{...TransitionProps}
@@ -323,30 +318,6 @@ Snackbar.propTypes = {
323318
* @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`.
324319
*/
325320
onClose: PropTypes.func,
326-
/**
327-
* Callback fired before the transition is entering.
328-
*/
329-
onEnter: PropTypes.func,
330-
/**
331-
* Callback fired when the transition has entered.
332-
*/
333-
onEntered: PropTypes.func,
334-
/**
335-
* Callback fired when the transition is entering.
336-
*/
337-
onEntering: PropTypes.func,
338-
/**
339-
* Callback fired before the transition is exiting.
340-
*/
341-
onExit: PropTypes.func,
342-
/**
343-
* Callback fired when the transition has exited.
344-
*/
345-
onExited: PropTypes.func,
346-
/**
347-
* Callback fired when the transition is exiting.
348-
*/
349-
onExiting: PropTypes.func,
350321
/**
351322
* @ignore
352323
*/

packages/material-ui/src/Snackbar/Snackbar.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('<Snackbar />', () => {
7676
<Snackbar
7777
open={false}
7878
onClose={handleClose}
79-
onExited={handleExited}
79+
TransitionProps={{ onExited: handleExited }}
8080
message="message"
8181
autoHideDuration={duration}
8282
transitionDuration={duration / 2}

0 commit comments

Comments
 (0)