React-native: [RN 0.52] New YellowBox.ignoreWarnings fail to ignore listed warnings

Created on 10 Jan 2018  路  10Comments  路  Source: facebook/react-native

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.3.0
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.52.0 => 0.52.0

Steps to Reproduce

$ react-native run-ios

Expected Behavior

iOS simulator run without showing ignored YellowBox warnings

Actual Behavior

screenshot 2018-01-09 14 53 14

Reproducible Demo

I have in index.js:

import React, {Component} from "react"
import {
  AppRegistry,
  StyleSheet,
  View,
  Dimensions,
  StatusBar,
  YellowBox,
} from 'react-native'
YellowBox.ignoreWarnings = ([
  'Encountered an error loading page',    // WebView uri: result.url and url failing to load - "bloomberg suneq" https://github.com/facebook/react-native/issues/7839#issuecomment-224111608
  'Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  'Task orphaned for request ',
  'Remote debugger is in a background tab which may cause apps to perform slowly',
])

This is not the case with the previous form: console.ignoredYellowBox = [...] prior to this change in RN 0.52. The 2 YellowBox warnings in screenshot above got properly ignored. Now in RN 0.52, the only way I can as a workaround suppress these YellowBox warnings is by adding a catch-all disable to my index.js:

console.disableYellowBox = true

Am I missing something in my `YellowBox.ignoreWarnings = ([...]) specs so they aren't actually ignoring?

Locked

Most helpful comment

I am running RN 0.55.2 and I followed the docs but I am still getting yellow box warnings with both a specific error to ignore and also trying console.disableYellowBox = true;. Neither case is effective at stopping any yellow box warning messages from popping up. I have wiped the app, cache, reinstalled, etc., no dice.
Any thoughts on how I can resolve this? Thx!

All 10 comments

Seems to be a error in the documentation. This works for me:

import {YellowBox} from 'react-native'
YellowBox.ignoreWarnings([
  'Encountered an error loading page',    // WebView uri: result.url and url failing to load - "bloomberg suneq" https://github.com/facebook/react-native/issues/7839#issuecomment-224111608
  'Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  'Task orphaned for request ',
  'Remote debugger is in a background tab which may cause apps to perform slowly',
])

Works. Leaving this issue open for release note and docs needing revision.

Just send a PR for revising the docs
https://github.com/facebook/react-native-website/pull/173

Documentation updated in 0.52 and next version. Thank you all.

I am running RN 0.55.2 and I followed the docs but I am still getting yellow box warnings with both a specific error to ignore and also trying console.disableYellowBox = true;. Neither case is effective at stopping any yellow box warning messages from popping up. I have wiped the app, cache, reinstalled, etc., no dice.
Any thoughts on how I can resolve this? Thx!

I've been using:

console.ignoredYellowBox = ['Setting a timer']; // Ignore Firebase timer issues.

This works against 0.51.1.

This is still an issue with 0.56.0. Neither of the solutions work. It's also a problem when encountering dynamically created warnings like the one below.

YellowBox.js:67 (ADVICE) View #17 of type RCTView has a shadow set but cannot calculate shadow efficiently. Consider setting a background color to fix this, or apply the shadow to a more specific component.

For me with 0.56.0 worked this
YellowBox.ignoreWarnings(["Warning:"]);
But I had to put it in the right file, that cause this error, not root file

Still an issue for me on 0.56

I've tried

console.disableYellowBox = true;

and almost all variations of YellowBox.ignoreWarnings in index.js and specific files that throw the warnings.

I had console.disableYellowBox = true; in App.js and it was working perfectly before. Stopped working when I updated react native. Moved it to index.js and now it works again.

Was this page helpful?
0 / 5 - 0 ratings