Skip to content

Commit

Permalink
[docs][material-ui][Snackbar] Improve reason type in demos (#43077)
Browse files Browse the repository at this point in the history
Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
  • Loading branch information
2 people authored and web-flow committed Jul 28, 2024
1 parent 4e38398 commit ca4acc0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions docs/data/material/components/snackbars/AutohideSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';

export default function AutohideSnackbar() {
const [open, setOpen] = React.useState(false);
Expand All @@ -9,7 +9,10 @@ export default function AutohideSnackbar() {
setOpen(true);
};

const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => {
const handleClose = (
event: React.SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';
import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';

Expand Down Expand Up @@ -32,7 +32,10 @@ export default function ConsecutiveSnackbars() {
setSnackPack((prev) => [...prev, { message, key: new Date().getTime() }]);
};

const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => {
const handleClose = (
event: React.SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';
import Alert from '@mui/material/Alert';

export default function CustomizedSnackbars() {
Expand All @@ -10,7 +10,10 @@ export default function CustomizedSnackbars() {
setOpen(true);
};

const handleClose = (event?: React.SyntheticEvent | Event, reason?: string) => {
const handleClose = (
event?: React.SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions docs/data/material/components/snackbars/SimpleSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';
import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';

Expand All @@ -11,7 +11,10 @@ export default function SimpleSnackbar() {
setOpen(true);
};

const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => {
const handleClose = (
event: React.SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
Expand Down

0 comments on commit ca4acc0

Please sign in to comment.