silence-react-unsafe-warnings.ts 663 B

123456789101112131415161718192021222324
  1. // eslint-disable-next-line no-console
  2. export const originalConsoleWarn = console.warn;
  3. const ignoredWarnings = [
  4. // React unsafe warnings.
  5. //
  6. // XXX(epurkhiser): This should be removed once we no longer have any `UNSAFE_`
  7. /componentWill.* has been renamed, and is not recommended for use.*/,
  8. // Moment failures. Why is this happening?
  9. /moment construction falls back/,
  10. ];
  11. window.console.warn = (message: any, ...args: any[]) => {
  12. if (
  13. typeof message === 'string' &&
  14. ignoredWarnings.some(warning => warning.test(message))
  15. ) {
  16. return;
  17. }
  18. originalConsoleWarn(message, ...args);
  19. };
  20. export const silencedWarn = window.console.warn;