Skip to content

Commit ab08882

Browse files
RDILoliviertassinari
authored andcommitted
[Dialog] Add deprecation warning for withMobileDialog (#23570)
1 parent 69f667b commit ab08882

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

docs/public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ https://material-ui.dev/* https://material-ui.com/:splat 301!
2222
/r/ts-issue-template https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcA5FDvmQNwBQokscA3nXHAPSdwwAWWOLhKQAdllEx0ATwgBXOHNRYAJnQC+cIiXIABEMhhYowZABsAtHOCdhlMnToE5o-MAii4AESwgIACgBKVnYuHgBNeSghCBUsDSA 302
2323
/r/custom-component-variants /customization/components/#adding-new-component-variants
2424
/r/x-license https://material-ui.com/store/items/material-ui-x/
25+
/r/migration-v4 https://next.material-ui.com/guides/migration-v4/
2526

2627
# Legacy redirection
2728
# Added in chronological order

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,25 @@ import * as React from 'react';
22
import PropTypes from 'prop-types';
33
import withWidth, { isWidthDown } from '../withWidth';
44

5+
let warnedOnce = false;
6+
57
/**
68
* Dialog will responsively be full screen *at or below* the given breakpoint
79
* (defaults to 'sm' for mobile devices).
810
* Notice that this Higher-order Component is incompatible with server-side rendering.
911
*/
1012
const withMobileDialog = (options = {}) => (Component) => {
13+
if (process.env.NODE_ENV !== 'production') {
14+
if (!warnedOnce) {
15+
console.warn(
16+
[
17+
'Material-UI: The `withMobileDialog` function is deprecated.',
18+
'Head to https://material-ui.com/r/migration-v4/#dialog for a migration path.',
19+
].join('\n'),
20+
);
21+
warnedOnce = true;
22+
}
23+
}
1124
const { breakpoint = 'sm' } = options;
1225

1326
function WithMobileDialog(props) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { expect } from 'chai';
33
import { createShallow } from '@material-ui/core/test-utils';
44
import Dialog from '../Dialog';
55
import withMobileDialog from './withMobileDialog';
6+
import { consoleWarnMock } from 'test/utils/consoleErrorMock';
67

78
describe('withMobileDialog', () => {
89
let shallow;
@@ -12,6 +13,11 @@ describe('withMobileDialog', () => {
1213

1314
before(() => {
1415
shallow = createShallow({ dive: true });
16+
consoleWarnMock.spy();
17+
});
18+
19+
after(() => {
20+
consoleWarnMock.reset();
1521
});
1622

1723
function isFullScreen(breakpoints, width) {

0 commit comments

Comments
 (0)