javascript - console.error in react-native throws red screen even when __DEV__ is false - Stack Overflow

admin2025-04-20  0

I'm building react-native app with Exponent and do some logging with console.error e.g. when network request fails etc. While it's helpful in development to see this red screen with error on simulator or real device, I'm getting this too when __DEV__ is set to false (seeing it is set so in logs) while the web says it shouldn't work like this.

How can I disable that for non-dev builds? Is there any other way than monkey-patching console.error?

I'm building react-native app with Exponent and do some logging with console.error e.g. when network request fails etc. While it's helpful in development to see this red screen with error on simulator or real device, I'm getting this too when __DEV__ is set to false (seeing it is set so in logs) while the web says it shouldn't work like this.

How can I disable that for non-dev builds? Is there any other way than monkey-patching console.error?

Share Improve this question asked Mar 13, 2017 at 8:30 Michal OstruszkaMichal Ostruszka 2,0992 gold badges21 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You are getting this fullscreen error until you run your app in production mode. That means you need to run your iOS/Android app in production.

If you want to do it with iOS you need to change your Scheme to Release

More details can be found here

Just to add to the answer by Tobias Lins, for the sake of pleteness.

You can also use the following, both in prod and debug builds:

import { LogBox } from 'react-native';

// Ignore on a per-message basis
LogBox.ignoreLogs(['Warning: ReactNative.createElement is deprecated…']);

// Ignore all
LogBox.ignoreAllLogs();
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745081566a283890.html

最新回复(0)