New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENV variables are not loaded at runtime #199
Comments
Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/199 |
My guess is that babel recompiles the file when you make the change of adding the console.log . I don't know why but I advise you try to invalidate the cache in your babel config https://github.com/goatandsheep/react-native-dotenv-metro-demo/blob/c0daeebe35a87c524eb88803e19f445d6d6956d4/babel.config.js#L2 |
Not sure why this isn't working for me either. But as you mentioned, if there is a
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
has anyone figured out a more elegant solution to this? |
I'm working on using a new Babel feature that came out this year but it has not been widely used so documentation has been challenging to follow. Fix should be in next release, tracked in #75 |
I just solved the issue, need to run yarn start --reset-cache, then it runs like a dream |
Hi @Ryanjso this ticket is closed because I haven't been able to reproduce it since recent changes. Make sure your Babel version is up to date or if you're using Expo that you're using the latest version of that or if you're using something else that is forcing the version of Babel down that you use package resolutions |
Describe the bug
ENV variables are not loaded at runtime. Old env variables are getting assigned in components and works if console logs are added.
To Reproduce
Steps to reproduce the behavior:
"cc": "rimraf node_modules/.cache/babel-loader/*,", "android": "npm run cc && react-native run-android",
Expected behavior
Above code should work after changing THEME="theme2" & DEFAULT_MODE="no" and rebuilding app using
npm run android
and headerShown value should be false** Error**
Above code still points to DEFAULT_MODE="yes" and works i.e. headerShown value updates to false only if there is console statement after import in every file. i.e
import {THEME, DEFAULT_MODE} from "@env"; console.log("THEME CHECK",THEME, DEFAULT_MODE);
React native version used:
"react": "16.13.1",
"react-native": "0.63.3",
The text was updated successfully, but these errors were encountered: