1

In my app I have to use different API endpoints depending on the type of build. Up till now I was always changing the api variable manually before each build, but now I wan't to see if this can be automated. Has anyone come up with a simple solution to this? I imagine this to be a check when the app is bundling, and if say the build is 'release', the api variable should be X.

Annie Hill
  • 379
  • 3
  • 16
  • 1
    There are very nice libraries that solve this problem, such as https://github.com/luggit/react-native-config – nbokmans Feb 22 '19 at 10:14

1 Answers1

0

Not sure if it's a good idea but you can use __DEV__ global variable in JavaScript to determine if you're using React Native packager or not

const randomVar = __DEV__ ? 'devValue' : 'releaseVal';
Isaac
  • 12,042
  • 16
  • 52
  • 116