Using React Native
I would like to keep working in debug
or __DEV__
mode but without the red screens.
Does someone know how to disabled it or change console.error
implementation?
I've tried to do something like this:
console.error = {};
Or
console.error = () => {};
But none of the above worked.
Any idea?
Use:
console.reportErrorsAsExceptions = false;
https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/Libraries/Core/ExceptionsManager.js#L97
Works for me.
After reading the react-native code I managed to stop the red screen with
console._errorOriginal = console.error.bind(console);
console.error = () => {};
Add this to your app's entry point JS file:
import {NativeModules} from 'react-native';
NativeModules.ExceptionsManager = null;
It will disable the native module that's responsible for showing the red-box window (reportSoftException
, or reportFatalException
called from react-native/Libraries/Core/ExceptionsManager.js
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With