YellowBoxDeprecated.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow
  8. * @format
  9. */
  10. 'use strict';
  11. const React = require('react');
  12. const LogBox = require('../LogBox/LogBox');
  13. import type {IgnorePattern} from '../LogBox/Data/LogBoxData';
  14. type Props = $ReadOnly<{||}>;
  15. let YellowBox;
  16. if (__DEV__) {
  17. YellowBox = class extends React.Component<Props> {
  18. static ignoreWarnings(patterns: $ReadOnlyArray<IgnorePattern>): void {
  19. console.warn(
  20. 'YellowBox has been replaced with LogBox. Please call LogBox.ignoreLogs() instead.',
  21. );
  22. LogBox.ignoreLogs(patterns);
  23. }
  24. static install(): void {
  25. console.warn(
  26. 'YellowBox has been replaced with LogBox. Please call LogBox.install() instead.',
  27. );
  28. LogBox.install();
  29. }
  30. static uninstall(): void {
  31. console.warn(
  32. 'YellowBox has been replaced with LogBox. Please call LogBox.uninstall() instead.',
  33. );
  34. LogBox.uninstall();
  35. }
  36. render(): React.Node {
  37. return null;
  38. }
  39. };
  40. } else {
  41. YellowBox = class extends React.Component<Props> {
  42. static ignoreWarnings(patterns: $ReadOnlyArray<IgnorePattern>): void {
  43. // Do nothing.
  44. }
  45. static install(): void {
  46. // Do nothing.
  47. }
  48. static uninstall(): void {
  49. // Do nothing.
  50. }
  51. render(): React.Node {
  52. return null;
  53. }
  54. };
  55. }
  56. module.exports = (YellowBox: Class<React.Component<Props>> & {
  57. ignoreWarnings($ReadOnlyArray<IgnorePattern>): void,
  58. install(): void,
  59. uninstall(): void,
  60. ...
  61. });