create-react-app environment-variables reactjs

React env variables with .env

I’m trying to follow docs on adding env variables from react-create-app without success:

enter image description here

  • inside root of the document I have a “.env” file (default .env properties)
  • .env file contains only one variable ‘REACT_APP_API_HOST=http://localhost:8080
  • trying to access process.env inside my app (created with create react app) gives me undefined

This is app.js where I’m trying to access process.env without success.

I can’t access process.env inside the code. Is there any working example on how to do it?