I added the react-native-dotenv
library and followed the guide using TypeScript.
I created a .env
file
MARVEL_API = <url>MARVEL_PUBLIC_KEY = <public-key>MARVEL_PRIVATE_KEY = <private-key>
I added this options at babel.config.js
file at the presets
'module:react-native-dotenv', { moduleName: '@env', path: '.env', whitelist: ['MARVEL_API', 'MARVEL_PUBLIC_KEY', 'MARVEL_PRIVATE_KEY'], safe: false, allowUndefined: true, },
I created a types
folder with the end.d.ts
file and I declared the @env as
declare module '@env' { export const MARVEL_API: string; export const MARVEL_PUBLIC_KEY: string; export const MARVEL_PRIVATE_KEY: string;}
Whe I saved the files, launched this error:
error: index.js: [BABEL] /home/vagner/Documents/www/objective/index.js: Unknown option: .name. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
I saw to write yarn start --reset-cache
but it did not work.