Skip to content

Commit

Permalink
don't use warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Sep 21, 2020
1 parent 6ea7f9f commit ea8ad32
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
1 change: 1 addition & 0 deletions packages/material-ui-lab/src/Alert/Alert.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import Alert from '@material-ui/core/Alert';

export default Alert;
26 changes: 12 additions & 14 deletions packages/material-ui-lab/src/Alert/Alert.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React from 'react';
import warning from 'warning';
import Alert from '@material-ui/core/Alert';

let warnedOnce = false;

export default React.forwardRef(function DeprecatedAlert(props, ref) {
let warnedOnce = false;

warning(
warnOnce,
if (!warnedOnce) {
console.warn(
[
'Material-UI: the Alert component was moved from the lab to the core.',
'',
"You should use `import { Alert } from '@material-ui/core'`",
"or `import Alert from '@material-ui/core/Alert'`",
].join('\n'),
);

[
'Material-UI: the Alert component was moved from the lab to the core.',
'',
"You should use `import { Alert } from '@material-ui/core'`",
"or `import Alert from '@material-ui/core/Alert'`",
].join('\n'),
);

warnOnce = true;
warnedOnce = true;
}

return <Alert ref={ref} {...props} />;
});
1 change: 1 addition & 0 deletions packages/material-ui-lab/src/AlertTitle/AlertTitle.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import AlertTitle from '@material-ui/core/AlertTitle';

export default AlertTitle;
26 changes: 13 additions & 13 deletions packages/material-ui-lab/src/AlertTitle/AlertTitle.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react';
import warning from 'warning';
import AlertTitle from '@material-ui/core/AlertTitle';

export default React.forwardRef(function DeprecatedAlertTitle(props, ref) {
let warnOnce = false;
let warnedOnce = false;

warning(
warnOnce,
[
'Material-UI: the AlertTitle component was moved from the lab to the core.',
'',
"You should use `import { AlertTitle } from '@material-ui/core'`",
"or `import AlertTitle from '@material-ui/core/AlertTitle'`",
].join('\n'),
);

warnOnce = true;
if (!warnedOnce) {
console.warn(
[
'Material-UI: the AlertTitle component was moved from the lab to the core.',
'',
"You should use `import { AlertTitle } from '@material-ui/core'`",
"or `import AlertTitle from '@material-ui/core/AlertTitle'`",
].join('\n'),
);

warnedOnce = true;
}

return <AlertTitle ref={ref} {...props} />;
});

0 comments on commit ea8ad32

Please sign in to comment.