This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Optional import? #41
Comments
You could set your env variable to a empty string and check its length to determine if it's been set or not. For example: In .env:
In your code somewhere:
Hope that helps! |
Thanks, but it would be nicer to not have to define all the optional environment variables like in other dotenv libraries for other programming languages. |
Phil-Barber
pushed a commit
to Phil-Barber/react-native-dotenv
that referenced
this issue
Dec 30, 2019
Any success on this? |
florian-milky
added a commit
to florian-milky/react-native-dotenv
that referenced
this issue
Mar 26, 2020
[allow-undefined] closes zetachang#41
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm importing MOCK_CURRENT_LOCATION_LATITUDE from react-native-dotenv, however I'm not expecting it to always be set, and thus in the code I check with an if to see if it's set.
Instead I get Try to import dotenv variable "MOCK_CURRENT_LOCATION_LATITUDE" which is not defined in any .env files. and a redbox error for it even though I intentionally do not want it set in my env.
What am I supposed to do to have optional environment variables?
The text was updated successfully, but these errors were encountered: