How to disable the red screen in debug mode

Using React Native, I would like to continue to work in debugor __DEV__without, but without red screens.

Does anyone know how to disable it or change the implementation console.error?

I tried to do something like this:

console.error = {};

or

console.error = () => {};

But there was none of this.

Any idea?

+4
source share
3 answers

you can try add

 console.error = (error) => error.apply;

this will solve your problem.

or use

console.disableYellowBox = true;

if you want to disable warnings

+1
source

Add this to your application entry point JS file:

import {NativeModules} from 'react-native';
NativeModules.ExceptionsManager = null;

It will disable its own module, responsible for displaying a window with a red field ( reportSoftExceptionor reportFatalException, called from react-native/Libraries/Core/ExceptionsManager.js)

+1

Source: https://habr.com/ru/post/1680173/


All Articles