Questions tagged [react-native]
React Native is a JavaScript library used to build native mobile apps using React. The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere.
react-native
8,075
questions
50
votes
5
answers
57k
views
React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0
Note: Error may be different but if you are getting any error when taking android build without any changes in code for past two days
My Error - Failed to install the app. Error: Command failed: ./...
151
votes
17
answers
393k
views
if-else statement inside jsx: ReactJS
I need to change render function and run some sub render function when a specific state given,
For example:
render() {
return (
<View style={styles.container}>
if (...
142
votes
17
answers
201k
views
React Native - Image Require Module using Dynamic Names
I'm currently building a test app using React Native. The Image module thus far has been working fine.
For example, if I had an image named avatar, the below code snippet works fine.
<Image source={...
426
votes
56
answers
439k
views
Unable to load script from assets index.android.bundle on windows
I'm trying to run my first React Native project for first time on my device (Android 4.2.2).
And I get:
unable to load script from assets index.android.bundle
Commands that I used:
cd (project ...
238
votes
42
answers
466k
views
React Native fetch() Network Request Failed
When I create a brand new project using react-native init (RN version 0.29.1) and put a fetch in the render method to the public facebook demo movie API, it throws a Network Request Failed. There is a ...
4
votes
1
answer
4k
views
Pass Data to Service in Axios
I want to set _boundry in my header.
First, I dispatch the form data:
//component.js
const form = new FormData();
form.append('email', '[email protected]')
form.append('password', '12121212')
...
194
votes
33
answers
434k
views
Generate SHA-1 for Flutter/React-Native/Android-Native app
I'm trying to generate a SHA-1 for a Flutter app, for Android studio to support Google Sign in, but I don't know how to do that, I saw some posts that indicate to run a command, but there I need a jks ...
124
votes
17
answers
169k
views
React Native Android Fetch failing on connection to local API
I'm using the fetch API in my react-native Android app to make requests to a local API. I usually query said API from react web apps at http://localhost:8163.
I'm testing my app on my physical device ...
298
votes
14
answers
554k
views
ReactJS: Maximum update depth exceeded error
I am trying to toggle the state of a component in ReactJS but I get an error stating:
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside ...
140
votes
47
answers
292k
views
Error:(23, 17) Failed to resolve: junit:junit:4.12
Why is it that every time I create a new project in Android Studio, it always comes up with:
Error:(23, 17) Failed to resolve: junit:junit:4.12?
When I remove testCompile 'junit:junit:4.12' in ...
134
votes
19
answers
360k
views
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
I built an app with ReactNative both for iOS and android with a ListView. When populating the listview with a valid datasource, the following warning is printed at the bottom of the screen:
Warning:...
329
votes
25
answers
378k
views
React Native: How to select the next TextInput after pressing the "next" keyboard button?
I defined two TextInput fields as follows:
<TextInput
style = {styles.titleInput}
returnKeyType = {"next"}
autoFocus = {true}
placeholder = "Title" />
<TextInput
style = {...
16
votes
2
answers
35k
views
How can scheduled Firebase Cloud Messaging notifications be made outside of the Firebase Console?
Inside the Firebase Console, under the Cloud Messaging view, users are able to create test notifications. This functionality also allows you to schedule the time at which the notification will send to ...
160
votes
10
answers
224k
views
How to register event with useEffect hooks?
I am following a Udemy course on how to register events with hooks, the instructor gave the below code:
const [userText, setUserText] = useState('');
const handleUserKeyPress = event => {
...
596
votes
35
answers
580k
views
React Native android build failed. SDK location not found
I have error when i start running android
What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or ...
70
votes
11
answers
66k
views
React Native: require() with Dynamic String?
I have read several posts about issues that people are having with React Native and the require() function when trying to require a dynamic resource such as:
Dynamic (fails):
urlName = "sampleData....
39
votes
5
answers
12k
views
Viable options for running NodeJS on Android (Aug 2017)
There are a bunch of old SO threads dealing with running NodeJS on Android. Most of these are no longer viable (JXCore) and/or provide confusing, outdated, incomplete, or erroneous information.
...
925
votes
45
answers
424k
views
What is the difference between React Native and React?
I have started to learn React out of curiosity and wanted to know the difference between React and React Native - though could not find a satisfactory answer using Google. React and React Native seems ...
244
votes
24
answers
287k
views
Setting environment variable in react-native?
I am using react-native to build a cross-platform app, but I do not know how to set the environment variable so that I can have different constants for different environments.
Example:
development:
...
139
votes
45
answers
154k
views
Print: Entry, ":CFBundleIdentifier", Does Not Exist
When I run react-native run-ios the build succeeds but I get the error below. I've checked all over the place but nothing seems to be working. Using sudo in front of the command does not help either. ...
365
votes
6
answers
202k
views
What are my options for storing data when using React Native? (iOS and Android) [closed]
I am still new in the React Native world, and generally in the mobile/native world as well, and I am finding the documentation a bit lacking when it comes to data persistence.
What are my options for ...
219
votes
19
answers
284k
views
Build and Install unsigned apk on device without the development server?
As I am new in react-native so if there is anything wrong in steps let me know.
I have build a react native android app using the command as per documentation
react-native android
while running ...
351
votes
12
answers
183k
views
What is the difference between Expo and React Native?
From the Expo website
Expo lets web developers build truly native apps that work across both iOS and Android by writing them once in just JavaScript.
Isn't this what React Native does? What's the ...
328
votes
22
answers
561k
views
How can I generate an apk that can run without server with react-native?
I've built my app, I can run it on my local emulator (and also on my android device within the same network by changing debug server).
However, I want to build an APK that I can send to someone ...
84
votes
5
answers
129k
views
Where can I make API call with hooks in react?
Basically we do API calls in componentDidMount() life cycle method in React class components like below
componentDidMount(){
//Here we do API call and do setState accordingly
}
...
10
votes
2
answers
4k
views
404 Not Found when trying to install ESLint 8.4.4 with create-react-app
Whenever I try to run npx create-react-app my-app, it shows the error:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz - Not found
npm ERR! ...
208
votes
26
answers
138k
views
Android failed to load JS bundle
I'm trying to run AwesomeProject on my Nexus5 (android 5.1.1).
I'm able to build the project and install it on the device. But when I run it, I got a red screen saying
Unable to download JS bundle. ...
185
votes
35
answers
382k
views
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65
I've build a react-native application and suddenly I get this error message on my terminal during run of the command react-native run-ios.
The same code work fine 10 minutes ago and suddenly I get ...
92
votes
14
answers
71k
views
How to auto-slide the window out from behind keyboard when TextInput has focus?
I've seen this hack for native apps to auto scroll the window, but wondering best way to do it in React Native... When a <TextInput> field gets focus and is positioned low in the view, the ...
80
votes
9
answers
241k
views
Render HTML in React Native
In my React Native app, I am pulling in JSON data that has raw HTML elements like this: <p>This is some text. Let’s figure out...</p>
I've added the data to a view in my app ...
358
votes
38
answers
493k
views
Hide header in stack navigator React navigation
I'm trying to switch screens using both stack and tab navigator.
const MainNavigation = StackNavigator({
otp: { screen: OTPlogin },
otpverify: { screen: OTPverification},
...
189
votes
52
answers
244k
views
"Text strings must be rendered within a <Text> component"
I've upgraded from React Native 0.54 to 0.57 and my application has fallen over, due to using React Native elements.
I used the error functionality of TextInput components, which enabled props that ...
102
votes
21
answers
204k
views
React navigation goBack() and update parent state
I've a page that will render the user's name if s/he is logged in or "Create an account" or "Sign in" option if s/he not. Screen as below
They can navigate to "Sign in" or "Create an account" page. ...
3
votes
2
answers
9k
views
Adding new data to firebase users
I want to add a new data to firebase authentication which has data like displayname, phone number, image. But i want to add more such gender, birthday and more. is it possible to add new?
709
votes
38
answers
454k
views
Hide keyboard in react-native
If I tap onto a textinput, I want to be able to tap somewhere else in order to dismiss the keyboard again (not the return key though). I haven't found the slightest piece of information concerning ...
232
votes
14
answers
344k
views
What is useState() in React?
I am currently learning hooks concept in React and trying to understand below example.
import { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call &...
227
votes
20
answers
434k
views
How can I force a component to re-render with hooks in React?
Considering below hooks example
import { useState } from 'react';
function Example() {
const [count, setCount] = useState(0);
return (
<div>
<...
215
votes
12
answers
249k
views
NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll
Recently I started to get this error:
NSPhotoLibraryUsageDescription key must be present in Info.plist to
use camera roll.
I am using React Native to build my app (I am not familiar with ios ...
212
votes
39
answers
179k
views
error "Could not get BatchedBridge, make sure your bundle is packaged properly" on start of app
Trying to create a react-native project on Android 4.4.2 I get this error screen
and couldn't find any way to resolve it. I tried restarting packager, reconnecting device, even reinstalling react ...
93
votes
4
answers
88k
views
What is StrictMode in React?
I heard that strict mode helps to write React code in best practices way by throwing warnings for life cycle methods removal. I read about it from this article on Medium.
Is my understanding correct? ...
82
votes
5
answers
110k
views
react native use variable for image file
I know that to use a static image in react native you need to do a require to that image specifically, but I am trying to load a random image based on a number. For example I have 100 images called ...
0
votes
2
answers
3k
views
Remembering state before app goes in foreground
I have a react native project and i have to implement a feature that when app is inactive it renders a logo screen and when app is active it renders the app.
I was able to accomplish this but my ...
346
votes
71
answers
316k
views
Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release
react-native run-android command terminates by leaving a message in android simulator. The message is as follows:
Unable to load script.Make sure you are either running a Metro server or that your ...
313
votes
76
answers
256k
views
What is the meaning of 'No bundle URL present' in react-native?
When I run a react-native project, I get a error no bundle URL present, but I don't know what mistakes I do, I was very confused.
276
votes
50
answers
218k
views
React Native version mismatch
Getting the following message when I init a new project and then launch the Xcode emulator:
React-Native Version Mismatch
Javascript Version 0.50.1
Native version: 0.50.0
Make sure you ...
214
votes
22
answers
436k
views
react-native: command not found
I am getting -bash: react-native: command not found error while creating a react-native project.
Below are the additional info
1. brew --version
homebrew 0.9.9
2 brew info watchman
watchman `...
208
votes
9
answers
141k
views
Is using async componentDidMount() good?
Is using componentDidMount() as an async function good practice in React Native or should I avoid it?
I need to get some info from AsyncStorage when the component mounts, but the only way I know to ...
201
votes
16
answers
219k
views
How can I view network requests (for debugging) in React Native?
I'd like to view my network requests in React Native to help me debug - ideally in the 'Network' tab of Chrome's devtools.
There are some closed issues about this on GitHub (https://github.com/...
139
votes
16
answers
231k
views
Failed to find Build Tools revision 23.0.1
I am trying to build my first app with react-native.
I am following these 2 tutorial:
https://facebook.github.io/react-native/docs/getting-started.html#content
https://facebook.github.io/react-...
126
votes
7
answers
422k
views
React Native: Possible unhandled promise rejection
I'm getting the following error:
Possible unhandled promise rejection (id:0: Network request failed)`
Here's the promise code, I don't see what's wrong here, any ideas?
return fetch(url)
....