ignite-bowser icon indicating copy to clipboard operation
ignite-bowser copied to clipboard

Not clear on how to use environment variables

Open nonameolsson opened this issue 3 years ago • 2 comments


What's going on?

In the Ignite Bowser Expo template, there is an .env file. I can’t see that it is used in the boilerplate. It also says in the comment:

# This is an example where you can store your environment variables.
# It uses react-native-dotenv as a babel transform.
#
# Then just do this to import them:
# import { API_URL } from ‘react-native-dotenv’

The instructions on how to use environment variables doesn't seem to be up-to-date because react-native-dotenv isn't included in package.json.

Is this just some old code still laying around, or should the comment include some instructions that a user should add that package? Or should that package be included in the boilerplate?

Since the boilerplate now supports Expo, maybe expo-constants should be the preferred way of using environment variables. https://docs.expo.io/guides/environment-variables/

At the same time, the folder app/config/ contains files that allows a user to use those as some kind of environment variables.


Steps to reproduce

  1. Generate a new app
  2. Follow the instructions in .env
  3. Error

ignite doctor results:

System
  platform           darwin                                                 
  arch               x64                                                    
  cpu                8 cores      Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz 
  directory          bowser       /Users/andreasolsson/Code/bowser          

JavaScript
  node               12.18.2      /Users/andreasolsson/.asdf/installs/nodejs/12.18.2/bin/node 
  npm                6.14.5       /Users/andreasolsson/.asdf/installs/nodejs/12.18.2/bin/npm  
  yarn               1.22.4       /Users/andreasolsson/.yarn/bin/yarn                         

Ignite
  ignite-cli           3.5.2              /Users/andreasolsson/.asdf/installs/nodejs/12.18.2/.npm/bin/ignite     
  ignite src           build              /Users/andreasolsson/.config/yarn/global/node_modules/ignite-cli/build 
  navigation           react-navigation                                                                          
  generators                                                                                                     
                       component          ignite-bowser                                                          
                       model              ignite-bowser                                                          
                       navigator          ignite-bowser                                                          
                       screen             ignite-bowser                                                          
  createdWith          3.5.2                                                                                     
  boilerplate          ignite-bowser                                                                             
  boilerplateVersion   5.3.0                                                                                     

Android
  java               14.0.2       /usr/bin/java 
  android home       -            undefined     

iOS
  xcode              11.6       
  cocoapods          1.9.3        /usr/local/bin/pod 

nonameolsson avatar Aug 18 '20 20:08 nonameolsson

Maybe this is related #194 #274 ?

nonameolsson avatar Aug 18 '20 20:08 nonameolsson

Any update? I am using Ignite Flame and wondering the same thing. Instead of accessing the dev menu to toggle storybook UI (which doesn't appear to be working), I'd rather just pass a variable to expo start --storybook=true to run the story ok.

tyler-jewell avatar Feb 28 '21 22:02 tyler-jewell