I'm trying to determine if an application is currently running on localhost. On the web, I can use window.location to define localhost in the url string. I am using Androud Studio to emulate android devices expo. How do I tell if I'm in development mode in React Native?
CodePudding user response:
You can use the global variable __DEV__
The definition from the documentation is:
This variable is set to true when react-native is running in Dev mode
Example:
const myEnv = __DEV__ ? 'DEV' : 'PROD';
.....
<Text>{myEnv}</Text>