最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览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();
发布评论

评论列表(0)

  1. 暂无评论