You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just upgraded from RN 0.75 to RN 0.76 (new architecture enabled; rn-config v1.5.3) and now have the issue that the Config object appears to be empty. When i log it, it will look like this, with no fields i've defined in my .env file: {"getConstants": [Function getConstants], "toString": [Function toString]}
Apparently the fields now only get resolved and stored after you access them once directly in your code.
So when i write e.g. Config.API_URL, it would return the URL and if i would now log the Config object, it will include the URL.
Now that means if you access the fields directly through the Config object, it might not be an issue. However in my case i've added a wrapper so that i can parse the Environment fields before i access them, so i can have proper types and auto completion. File looks like this:
import dotenvParseVariables from 'dotenv-parse-variables';
import { Config } from 'react-native-config';
type Env = {
ENV: string;
API_URL: string;
FEATURE_ENABLED: boolean;
};
export const ENV = dotenvParseVariables(Config as { [key: string]: string }) as Env;
Now if i would adjust the code like this, where i first access the fields directly through the Config then they would stay available and i could parse them like before.
I just upgraded from RN 0.75 to RN 0.76 (new architecture enabled; rn-config v1.5.3) and now have the issue that the Config object appears to be empty. When i log it, it will look like this, with no fields i've defined in my .env file:
{"getConstants": [Function getConstants], "toString": [Function toString]}
Apparently the fields now only get resolved and stored after you access them once directly in your code.
So when i write e.g.
Config.API_URL
, it would return the URL and if i would now log the Config object, it will include the URL.Now that means if you access the fields directly through the Config object, it might not be an issue. However in my case i've added a wrapper so that i can parse the Environment fields before i access them, so i can have proper types and auto completion. File looks like this:
Now if i would adjust the code like this, where i first access the fields directly through the Config then they would stay available and i could parse them like before.
Not sure if this is the intended behaviour
The text was updated successfully, but these errors were encountered: