简体   繁体   中英

Trying to retrieve value from environment file getting undefined in react js

Hi all i have set the variable in environment file like as below

REACT_APP_RECIPIENT_MAIL="a@a.com,b@a.com,c@a.com"

and then i am retrieving those like as below

  let toArr;
  if (isDevelopmentMode()) {
    const mailList = process.env.REACT_APP_RECIPIENT_MAIL;
    console.log(mailList);
    toArr = mailList.split(',');
  } else {
    toArr = Array.isArray(to) ? to : [to];
  }
  const toAddrs = toArr.map(toAddr => ({
    emailAddress: {
      address: toAddr
    }
  })); 

getting undefined at this line console.log(mailList); for mailList and i am not sure where i am doing wrong with the above code, Could any one please suggest any ideas on this?

Many thanks in advance.

要使新添加的 env 变量可用,您需要停止 React 服务器并使用npm start重新启动它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM