React Native DEV and PROD variables

前端 未结 2 556
南笙
南笙 2020-11-30 09:20

How do I know if my React Native app is running in production or development? Is there some sort of way within JavaScript to tell? Is there a global that is passed in?

相关标签:
2条回答
  • 2020-11-30 10:11

    When the __DEV__ variable is set to true, it turns on a bunch of useful development warnings. For production, it is recommended to set __DEV__=false.

    0 讨论(0)
  • 2020-11-30 10:17

    You can use the __DEV__ global variable in JavaScript to determine if you're using React Native packager or not. If you are running your app in the iOS Simulator or Android emulator __DEV__ will be set to true.

    https://facebook.github.io/react-native/docs/javascript-environment.html

    0 讨论(0)
提交回复
热议问题