20

You can turn development mode on and off in the expo XDE, but how do you detect it in your code so you can switch on debug logging or do something differently for the debug build? Their docs show how to enable it, and see it in the UI, but not how to test for it in code.

boatcoder
  • 17,525
  • 18
  • 114
  • 178

2 Answers2

19

This always works for me. No need to look in the packagerOpts.

if (__DEV__) {
  // do dev stuff 
}
GollyJer
  • 23,857
  • 16
  • 106
  • 174
2

My last question was answered with let isDev = packagerOpts && packagerOpts.dev which is in Constants.manifest

https://forums.expo.io/t/constants-manifest-packageropts-dev-is-undefined/10890/5

ericjam
  • 1,501
  • 2
  • 20
  • 30