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.
7,409
questions
42
votes
4
answers
18k
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: ./...
127
votes
17
answers
313k
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 (...
409
votes
51
answers
400k
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 ...
130
votes
16
answers
175k
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={...
212
votes
36
answers
384k
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 ...
158
votes
31
answers
286k
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 ...
3
votes
1
answer
3k
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', 'eray@serviceUser.com')
form.append('password', '12121212')
...
274
votes
14
answers
469k
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 ...
139
votes
47
answers
283k
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 ...
13
votes
2
answers
22k
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 ...
100
votes
15
answers
123k
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 ...
326
votes
11
answers
153k
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 ...
307
votes
23
answers
331k
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 = {...
137
votes
9
answers
177k
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 => {
...
39
votes
5
answers
11k
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.
...
136
votes
45
answers
150k
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. ...
347
votes
6
answers
169k
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 ...
211
votes
16
answers
255k
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 ...
127
votes
19
answers
311k
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:...
60
votes
11
answers
53k
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....
566
votes
34
answers
480k
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 ...
308
votes
22
answers
469k
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 ...
10
votes
2
answers
3k
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! ...
230
votes
22
answers
238k
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:
...
208
votes
26
answers
133k
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. ...
91
votes
14
answers
68k
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 ...
78
votes
5
answers
103k
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
}
...
3
votes
2
answers
7k
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?
925
votes
45
answers
393k
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 ...
658
votes
35
answers
378k
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 ...
209
votes
37
answers
162k
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 ...
209
votes
20
answers
366k
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>
<...
182
votes
16
answers
173k
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/...
0
votes
2
answers
2k
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 ...
301
votes
59
answers
252k
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 ...
273
votes
49
answers
197k
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 ...
230
votes
14
answers
334k
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 &...
201
votes
9
answers
129k
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
22
answers
368k
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 `...
198
votes
11
answers
210k
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 ...
138
votes
16
answers
225k
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-...
104
votes
7
answers
170k
views
React Native: Getting the position of an element
I am styling an Image component with flexbox to be in the center of the screen which works pretty well. Now I want a second Image component to be displayed directly on the top of the first one. The ...
97
votes
17
answers
177k
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. ...
86
votes
4
answers
75k
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? ...
80
votes
5
answers
103k
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 ...
71
votes
8
answers
195k
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 ...
3
votes
2
answers
8k
views
Navigate to screen after opening a notification?
I'm using Firebase cloud functions to send a remote notification to a specific device I got his FCM Token, and I receive it and works very well,
Here is my code to send a notification by Cloud ...
0
votes
1
answer
1k
views
StackNavigator through Component gives undefined error
I was trying to use StackNavigator for navigation and it works when I use it to go from one screen to the other as explained here. But when I try to have a subcomponent to navigate through itself, the ...
323
votes
36
answers
400k
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},
...
274
votes
65
answers
185k
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.