Sorry for the terse subject, but I don't know what else to say.
To install I ran:
yarn add react-native-config
react-native link react-native-config
I have .env file in my root folder:
API_URL=http://192.168.1.175:8080/graphql
At the entry point of my app I have:
import Config from 'react-native-config';
console.log(Config);
Which outputs:
APPLICATION_ID: "com.myapp"
BUILD_TYPE: "debug"
DEBUG: true
FLAVOR: ""
VERSION_CODE: 1
VERSION_NAME: "1.0"
And Config.API_URL is undefined.
Same result on iOS and Android. It seems dead simple, and I can't see what could be wrong other than a bug. Ideas?
Sorry, correction. It does work on iOS after react-native run-ios. No luck on Android after restarting the simulator, clearing cache and repackaging.
Hi Tim! did you add apply from... to your Gradle config as mentioned here?
https://github.com/luggit/react-native-config#extra-step-for-android
@pedro I just noticed that from another issue. Thanks. Might be good to add that to the linking if possible or make it more prominent in doc since it's not optional.
Sweet, thank you!
Most helpful comment
Hi Tim! did you add
apply from...to your Gradle config as mentioned here?https://github.com/luggit/react-native-config#extra-step-for-android