After enabling the experimental/unstable new logbox with
require('react-native').unstable_enableLogBox();
the warnings won't be disabled when setting
console.disableYellowBox = true;
The reason for this is that there many warnings generated even by RN itself and I'd like to ave them hidden
$ react-native info
info Fetching system and libraries information...
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Memory: 715.46 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.12.0 - /usr/local/bin/node
Yarn: 1.7.0 - ~/.npm-packages/bin/yarn
npm: 6.13.6 - ~/.npm-packages/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.8.4 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.2, 28.0.3, 29.0.3
Android NDK: 20.1.5948944
IDEs:
Android Studio: Not Found
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0
npmGlobalPackages:
react-native: Not Found
require('react-native').unstable_enableLogBox();console.disableYellowBox = true;The Yellow box (small toast in the new version) should not be there
n/a
Thank you 馃樆
Here is a temporary workaround in case someone needs:
import { YellowBox } from "react-native";
YellowBox.ignoreWarnings([""]);
That disables all warnings that start with an empty string, in other words, all warnings. This works even if unstable_enableLogBox is set.
It looks like console.disableYellowBox has been deprecated in favor of LogBox.ignoreAllLogs(). Can you try using that API instead?
@hramos I tried doing the same, but apparently, LogBox isn't exported yet, if I try to import it import { LogBox } from 'react-native' it comes back undefined. Or should I create a separate issue for that?
For some reason YellowBox.ignoreWarnings(['']); completely turns off my error box, when I raise an exception I see a white screen, if I uncomment this line, the error is shown with the new log box as expected.
Will this be available in react-native 0.63, that we can import LogBox and disable just the yellow warnings?
Hi fellas, any luck on this, I also can't seem to import LogBox from 'react-native' ???
Hi fellas, any luck on this, I also can't seem to import LogBox from 'react-native' ???
Are you using react-native 0.63? The docs indicate that this should work: https://reactnative.dev/docs/debugging#logbox
@nicoburns ~Yh currently using 0.63.1 and trying to ignore/disable some warnings but can't seem to import them~
Oops my bad, had the wrong version of the type definition installed 馃う
ReactNative.LogBox.ignoreAllLogs(true);
In React-Native 0.63, this will prevent annoying yellow warning box in screen.
You can add above line in root app function.
ReactNative.LogBox.ignoreAllLogs(true);
In React-Native 0.63, this will prevent annoying yellow warning box in screen.
You can add above line in root app function.
Can confirm that this works on 0.63^
import {LogBox} from 'react-native'
LogBox.ignoreAllLogs(true)
ReactNative.LogBox.ignoreAllLogs(true);
In React-Native 0.63, this will prevent annoying yellow warning box in screen.
You can add above line in root app function.Can confirm that this works on 0.63^
import {LogBox} from 'react-native' LogBox.ignoreAllLogs(true)yeah, my current React-Native version is 0.63.2
import {LogBox} from 'react-native'
LogBox.ignoreAllLogs(true)
Does not work for me on 0.63.2
The import does not work.
I'm on RN 0.63.3, and cannot import LogBox from 'react-native'.
Most helpful comment
@hramos I tried doing the same, but apparently,
LogBoxisn't exported yet, if I try to import itimport { LogBox } from 'react-native'it comes back undefined. Or should I create a separate issue for that?