0

Im trying to set up my env in react-native. I have install "react-native-dotenv": "^3.3.1".

In my babel.config.js I have the following:

  presets: ["module:metro-react-native-babel-preset"],
  plugins: [
    [
      "module:react-native-dotenv",
      {
        moduleName: "@env",
        path: ".env",
        blacklist: null,
        whitelist: null,
        safe: false,
        allowUndefined: false,
      },
    ],
  ],
};

I have a .env file in my root directory, inside i have

TEST_API = 123

in my file that I want to use the env, I imported it like this:

import {TEST_API}

when I try to use it {TEST_API} it does not work.

1
  • Check out this answer, that solves the same issue Commented Jun 18, 2022 at 7:12

1 Answer 1

1

Try with this one:

import {TEST_API} from '@env';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.