Skip to content

Commit

Permalink
Deprecate support for children in enqueueSnackbar options
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhosseindhv committed Mar 6, 2020
1 parent 76f8e19 commit ad6c5e1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
14 changes: 2 additions & 12 deletions src/SnackbarItem/SnackbarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Collapse from '@material-ui/core/Collapse';
import SnackbarContent from '@material-ui/core/SnackbarContent';
import { getTransitionDirection, getSnackbarClasses, getCollapseClasses } from './SnackbarItem.util';
import styles from './SnackbarItem.styles';
import { capitalise, MESSAGES, REASONS } from '../utils/constants';
import warning from '../utils/warning';
import { capitalise, REASONS } from '../utils/constants';


class SnackbarItem extends Component {
Expand Down Expand Up @@ -88,7 +87,6 @@ class SnackbarItem extends Component {
key,
persist,
variant,
children,
content: singleContent,
action: singleAction,
ContentProps: singleContentProps = {},
Expand Down Expand Up @@ -121,15 +119,7 @@ class SnackbarItem extends Component {
finalAction = contentProps.action(key);
}

let snackContent;
if (snack.children) {
snackContent = snack.children;
warning(MESSAGES.NO_CHILDREN_OPTION);
}
if (singleContent) {
snackContent = singleContent;
}
snackContent = snackContent || content;
let snackContent = singleContent || content;
if (snackContent && typeof snackContent === 'function') {
snackContent = snackContent(key, snack.message);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SnackbarProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ SnackbarProvider.propTypes = {
*/
dense: PropTypes.bool,
/**
* Used to easily display different variants of snackbars.
* Used to easily display different variant of snackbars. When passed to `SnackbarProvider`
* all snackbars inherit the `variant`, unless you override it in `enqueueSnackbar` options.
*/
variant: PropTypes.oneOf(
['default', 'error', 'success', 'warning', 'info'],
Expand Down
1 change: 0 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface OptionsObject extends Modify<Omit<SnackbarProps, RemovedAttribu
variant?: VariantType;
persist?: boolean;
preventDuplicate?: boolean;
children?: SnackbarContent; // To be deprecated
content?: SnackbarContent;
action?: SnackbarAction;
}
Expand Down
1 change: 0 additions & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const defaultIconVariant = {

export const MESSAGES = {
NO_PERSIST_ALL: 'WARNING - notistack: Reached maxSnack while all enqueued snackbars have \'persist\' flag. Notistack will dismiss the oldest snackbar anyway to allow other ones in the queue to be presented.',
NO_CHILDREN_OPTION: 'WARNING - notistack: \'children\' option in enqueueSnackbar has been deprecated and renamed to \'content\', and it will be removed in the next major release.',
};

export const SNACKBAR_INDENTS = {
Expand Down

0 comments on commit ad6c5e1

Please sign in to comment.