2

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?

Michal Ostruszka
  • 2,089
  • 2
  • 20
  • 23

1 Answers1

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

Gianfranco P.
  • 10,049
  • 6
  • 51
  • 68
Tobias Lins
  • 2,543
  • 19
  • 22
  • Thanks! But I don't get what does `__DEV__` really do? Because it seems like there are three different types of how app can behave: dev (with `__DEV__===true`, prod (with `Release` scheme) as you suggest and something in between (`__DEV__===false` but not `Release`) which is kind of crazy ;) – Michal Ostruszka Mar 13 '17 at 12:55
  • `__DEV__` can be used to run code pieces if it's you are developing or running the app in production. If you set your xcode to `Release`, `__DEV__` will be also false. You should avoid to use `console.error` then. Probably you can switch to `console.warn`. This will result in a `yellowbox` which can be disabled More infos [here](https://facebook.github.io/react-native/docs/debugging.html#warnings) – Tobias Lins Mar 13 '17 at 13:00
  • the console.error can break a production build somehow??? its very helpfull in developement, but iam afraid to break it in production. Cant find any docs about it – Neuber Oliveira May 03 '19 at 16:51
  • I didn't know that console.error throw an error in dev mode. I was struggling, trying to search where the throw comes from... Now I'm aware of that, thanks god ! haha – Emidomenge Apr 22 '20 at 14:25