Comments (5)
Hello @sumit96367 , after some research this is how I resolved it on my end
In my useFetch.js
import { RAPID_API_KEY } from '@env';
const rapidApiKey = RAPID_API_KEY;
and in my babel.config.js I added this ["module:react-native-dotenv"]
in plugin as below:
plugins: [
"@babel/plugin-proposal-export-namespace-from",
"react-native-reanimated/plugin",
require.resolve("expo-router/babel"),
["module:react-native-dotenv"],
],
Let me know if it works for you.
from project_react_native_jobs.
Hello @sumit96367 and everyone else who has this problem,
I've started with react native through JavaScriptMastery this week and I've been getting the same error. And here is my solution.
I added this to my app.json
, which I renamed as app.config.js
// app.config.js
import "dotenv/config"
export default {
// Default app.json
extra: {
// Default extra
rapidApiKey: process.env.RAPID_API_KEY,
// ...
}
}
If you don't have dotenv installed:
npm install --save-dev dotenv
Then to call these enviroment variables:
// useFetch.js
// ... imports
import Constants from "expo-constants"
const rapidApiKey = Constants.expoConfig.extra.rapidApiKey
// ...
If you don't have expo-constants installed:
npx expo install expo-constants
from project_react_native_jobs.
Hello @sumit96367 and everyone else who has this problem,
I've started with react native through JavaScriptMastery this week and I've been getting the same error. And here is my solution.
I added this to my
app.json
, which I renamed asapp.config.js
// app.config.js import "dotenv/config" export default { // Default app.json extra: { // Default extra rapidApiKey: process.env.RAPID_API_KEY, // ... } }If you don't have dotenv installed:
npm install --save-dev dotenvThen to call these enviroment variables:
// useFetch.js // ... imports import Constants from "expo-constants" const rapidApiKey = Constants.expoConfig.extra.rapidApiKey // ...If you don't have expo-constants installed:
npx expo install expo-constants
Thank you for this solution. This is my first time of learning react-native.
from project_react_native_jobs.
@JPaul23 @sumit96367 @adrianhajdin
After that, it will give and error like react-native-dotenv module not found so download the react-native-dotenv module.
npm install react-native-dotenv
Then it will work.
from project_react_native_jobs.
Related Issues (15)
- Category Info Object not found HOT 2
- Job sharing button not working. HOT 1
- Cannot read property 'id' of undefined HOT 1
- Undefined is not a function - handleCardPress HOT 1
- Font Apparently not loading? HOT 11
- Something went wrong in Popular and Nearby Jobs HOT 1
- ERROR in ./node_modules/expo-router/entry.js:
- unable to build project HOT 1
- Api problem? HOT 6
- Data Fetching / useFetch Hook not working as expected HOT 15
- setNativeProps is deprecated. Part-Time, Full-time, Contractor buttons not working
- Error: Couldn't find a navigation object. Is your component inside NavigationContainer?
- ScreenHeaderBtn(s) not getting displayed on the device screen HOT 6
- ScreenHeaderBtn not showing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from project_react_native_jobs.