react-native-dotenv icon indicating copy to clipboard operation
react-native-dotenv copied to clipboard

Converting string true/false to boolean value

Open lex111 opened this issue 7 years ago • 2 comments

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?

lex111 avatar Jul 16 '17 12:07 lex111

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

wachunei avatar Aug 08 '17 01:08 wachunei

@wachunei Yes but dotenv doesn't work with RN

pkantsedalov avatar Aug 09 '18 11:08 pkantsedalov