Is it possible to add custom developer options to your React Native app? For instance I would like to add the possibility to change the endpoint to which the app connects so I can switch between localhost, staging, production etc. on my mobile phone
With webpack you can use proccess.environment plugin, so you will be able to use
if (process.env.NODE_ENV === 'dev') {
makeYourThingIncludingRequereETC();
}
https://github.com/webpack/docs/wiki/list-of-plugins#environmentplugin
it will be transpiled to if ('prod' === 'dev') {}
in prod environment before build and minification, which will be removed from code due to 'always false' rule.
The best way to configure your react native app for different environments is to use
react-native-config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With