zetachang / react-native-dotenv

A Babel preset let you import application configs from .env file (zero runtime dependency)
MIT License
915 stars 68 forks source link

Converting string true/false to boolean value #23

Open lex111 opened 7 years ago

lex111 commented 7 years ago

For example, I have two variables:

ABC = true
XYZ = false

And in the code, I want to have a convenient check, like this:

import { ABC, XYZ } from 'react-native-dotenv';

if (XYZ) {
   // Always true
}

if (XYZ === 'true') {
   // Therefore it is necessary to do, then OK
}

Because otherwise string false will be counted as true, and the check will always be true.

Is it possible to do something?

wachunei commented 7 years ago

This is handled by dotenv (which is a dependency), check this out https://github.com/motdotla/dotenv/issues/51

pkantsedalov commented 6 years ago

@wachunei Yes but dotenv doesn't work with RN