Questions tagged [react-native]

19600 questions
1

votes
3

answer
1.1k

Views

react native how to get return from a promise

my problem is i want to get a json from this function but all i get is a only a promise and why i choose this way because in app that i'm working on it works dynamicly but the only place that i see i can put this promise is render() this is my code : var userInfo = (async()=>{ var value = await Asy...
shahabvshahabi
1

votes
1

answer
736

Views

react native xcode library not found for -lBranch-SDK

I have react native v0.49. After installing react-native-branch with this link link to react-native-branch, I try to run with xcode and I get the error ld: library not found for -lBranch-SDK in addition,when I run react-native-link I get react-native-branch ERR! Failed to add file to project
Adir Zoari
1

votes
0

answer
6

Views

Title not working on react-navigation createStackNavigator

I'm using createStackNavigator inside createBottomTabNavigator from react-navigation in my app. I want to have a title on my screen. Following React Navigation's tutorial I've implemented it this way: createBottomTabNavigator( { Home: createStackNavigator( {screen: HomePage, navigationOptions: () =...
Can Poyrazoğlu
1

votes
2

answer
1.6k

Views

Native Base button missing styling

I have a native-base app and the styling works but seems to be partially missing from buttons. There are no errors and I have applied no custom styles in my app. See the screenshot below. The buttons are missing their font color, padding, and maybe some other stuff. This is true for any button type...
austinbv
1

votes
1

answer
5.7k

Views

React Native: Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'response.json')

When I am trying to parse the response body in a json so I can save it in a state, I receive the error from the title. For some reason, the response.json is undefined. Here is my response: 16:28:30: Response { 16:28:30: '_bodyInit': '\'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImFkb...
Artyomska
1

votes
2

answer
431

Views

React Native, Redux, and Fetch: “Possible Unhandled Promise Rejection (id: 0)”

I am loading JSON data from a Webpage into my React Native app, and would like to store the data in Redux. I'm currently using Fetch like so: fetch('https://foo.com/product-data/product1.json') .then((response) => response.json()) .then((responseData) => this.state.productLoad(responseData)); where...
Steve
1

votes
2

answer
1.4k

Views

Reactjs code/naming conventions

Does anyone know if exists any official or most accepted reference for React naming conventions to use when we build our applications? React has a lot of different type of components such as React.Component, directives, services and so on. Wouldn't you agree that having a reference naming convention...
Rajendra Khabiya
1

votes
2

answer
4.7k

Views

Check axios request url before sending

API requests are failing because the URL generated by Axios is incorrect due to my config. I know what the request url is suppose to look like, so I want to see the request url Axios generates. I can point Axios to my local server and see the requests there, but I want to debug this on the client. I...
Dan
1

votes
3

answer
221

Views

How to get state of child component in react native

I have Main Component file and use in another child component. I have to get state of the child component. Ex :- Home (Parent) - Form (Child) component i have been set the value of any text box in state. So ho can i get the state value of Form component into the main component.
Asif vora
1

votes
2

answer
2.6k

Views

React Native - How to manage the native back button with Drawer Navigation

I recreated the Drawer Navigation following this code: https://github.com/mariodev12/react-native-menu-drawer-navigator Everything works correctly but now I do not know how to handle the native button to go back .. I would like to always return to the previous page, but if you press twice in the hom...
Nobady
1

votes
2

answer
2.2k

Views

React Native font scale

I have problem with scaling font inside of View or better to say inside of Text component in React Native for Android. The problem is, I want to text inside of Text component automatically scale depends on length of string (if text can fit inside View with desired font size do nothing and if it's st...
Newie
1

votes
1

answer
461

Views

AWS Amplify Push Notifications with React Native

There seem to be some discrepancies in the documentation as to how to implement Push Notifications. Here is the RN code from the AWS Amplify docs: import { PushNotificationIOS } from 'react-native'; import Analytics from '@aws-amplify/analytics'; import PushNotification from '@aws-amplify/pushnotifi...
Fook
1

votes
1

answer
1.6k

Views

Module 'react' does not exist in the Haste module map

I am trying to do LinkedIn integration in my app. So, I have done as below : Installed dependency as below : npm install react-native-linkedin --save; So, while launching the app, am getting below error : Failed to load bundle(http://localhost:8081/index.bundle? platform=ios&dev=true&minify=false...
Vishal Zaptech
1

votes
1

answer
787

Views

In App Purchases in React-Native Expo?

I'm wondering if there is a way to implement in-app purchases in Expo for an app that I'm developing. As I researched online, I haven't found a clear answer. Could anyone help Please?
trill
1

votes
2

answer
741

Views

React Native - Have view height set by content

I have a view and a scroll view that currently take up the full height due to the flex: 1 property. I'm trying to figure out how the have this view only take up the amount of space that the content within the scroll view takes up. Is this possible? ...
pizza-r0b
1

votes
1

answer
103

Views

TypeScript: is not assignable to boolean or PromiseLike

I'm writing a React Native app using TypeScript? I have written a function wrapper for functions from React Native Firebase like this: export const checkPermissions = (): Promise => new Promise((resolve, reject) => { firebase .messaging() .hasPermission() .then(enabled => { if (enabled) { return res...
J. Hesters
1

votes
2

answer
600

Views

Redux - call action from a function

I'm trying to call a redux action from a function. The component that I'm calling the function from is already connected to the store. However, it doesn't work if I pass the action such as: function myFunc(action) { action() } Is there a way to pass an action via a parameter? Thank you.
batatop
1

votes
3

answer
333

Views

Toggling the animated value in order to fade in/out the view

I'm trying to toggle view's opacity with animated value, by handling the button click, but I'm not getting the desired result, except the first time button is clicked, it fades out (opacity = 0) but when I press the button again nothing happens and I can't see my view. Here's the code: export defaul...
bra.Scene
1

votes
1

answer
52

Views

react-native-router-flux navigating to same scene

Is there a way to navigate to the scene that the user is currently on? Almost the equivalent of refreshing the component? I have a reusable component called ProfileScreen, which shows a user's profile. That user, by default, is the logged in user; but it can also be a user that they select on a diff...
NathanL
1

votes
2

answer
339

Views

Can't find variable: PropTypes

I am trying some react native code. Added props for my component based on the instructions given in this blog. End up in the error, Can't find variable: PropTypes Found the same question in github but it was closed without any answers Couldn't get any clues.
Sujananth
0

votes
0

answer
5

Views

Why is num not showing the correct value?

I am learning React-Native and building a game as a first app. I am building a flatlist of buttons based on a JSON fetch of results. The title of the button should be a number, ideally stating at 1,...n up to the n number of results. My test data set is 5. I have tried not incrementing num, where al...
hellohello
1

votes
0

answer
6

Views

Trouble with Yarn and Duplicate Modules from Jest

Alright let's see if i can even explain this well enough - I'm really hoping someone can provide some assistance because this is driving me crazy. We use yarn to pull packages for our RN projects. Let's say I have two versions of our project (more or less accurate, but easier to explain) version 0.5...
avanr
1

votes
1

answer
116

Views

yarn run ios - Error: Cannot find module - React Native

So, I'm setting up new React Native project, and I'm trying to setup XCode simulator. I've opened my React Native project in XCode and in the terminal when I run 'yarn run ios' from a project folder I'm getting the error 'Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault' at Fu...
T.Jurko
1

votes
3

answer
225

Views

How to select multiple values in flatlist based on there key

I'm using react native's powerful flatlist this is my array which is like this: data = [ {Color:[{'label':'BLUE','value':'10'}, {'label':'RED','value':'11'}]}, {Size:[{'label':'SMALL','value':'13'},{'label':'BIG','value':'12'}]} ] and here it Is my flatlist index.toString()} extraData={this.state...
Tanveerbyn
1

votes
1

answer
96

Views

Open Menu on click of Icon in React Native

I am not able to identify how to display Menu items when clicked on Icon in React Native Expo Link Code _onPressItem = () => { this.setState({ opened: true }); }; render() { return ( ); } getMenuView() { const { opened } = this.state; return ( this.onBackdropPress()} onSelect={value => this.onOption...
Sharath
1

votes
1

answer
35

Views

Updating chat messages efficiently (continuously) with Firebase's Firestore

I'm working on a React Native app that uses Firebase's Firestore for backend. Right now, every time a new message comes, I'm fetching all messages from the Firestore and updating my state, although it's just one new message that came. function listenCurrentChat(dispatch, chatID) { const address = 'c...
romin21
1

votes
1

answer
41

Views

Unable to render react-native Component after fetching data from firebase

I am able to fetch data from the Firebase API. I am able to set the state into the data received (I can see in Console). But when I am unable to render a Component (passing props as fetched data). Here' my code: class NewMeals extends Component { constructor(props){ super(props); this.state= { data:...
Saumay Paul
1

votes
2

answer
104

Views

Is it possible for a PWA to convert into a Native App?

Let's say a user visits https://mywebapp.com and starts using a PWA. Later down the road, the user gets prompted to install the PWA onto their device so that they may use it as a native app. My question is: Can this process go a step further, whereby the user gets prompted a 2nd time to install mo...
g.delgado
1

votes
1

answer
59

Views

Save state of TextInput array - React Native

I am fetching from API multiple TextInputs and displaying them on my screen. So, how can I save the state of user inputs to a global object. Something like this: state = { foundtextfields: [] } Here I am pushing those fetched TextInputs to foundTextFields[] array: var foundTextFields = []; foundText...
DoeDoe
1

votes
3

answer
49

Views

Can't call setState (or forceUpdate)

I'm seeing this error in the console and tried a lot of solutions nothing work ExceptionsManager.js:84 Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks...
Yousef Alsbaihi
1

votes
3

answer
42

Views

How do i Validations using Switch case or other way for less code in React native?

Is it possible to use Switch case for validation in React Native? Please give me Right way.Below is my code handleSubmit=()=>{ this.setState({ isLoading : true}); emailValid = /^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i; mobileValid = /^[0]?[789]\d{9}$/; if(this.state.first_name == ''){ this.setState({ i...
Chitra Nandpal
1

votes
2

answer
51

Views

How to align a Button to center on react native flatlist

I want to place a button on center of a flat list like the below image. Here is my code render() { return ( {Strings.SendMessage} ); } const styles = StyleSheet.create({ separator: { borderRadius: 4, borderWidth: 1, borderColor: colors.light_gray, }, footerStyle: { flexDirection: 'row', flex: 1, pa...
Rama
1

votes
3

answer
43

Views

The component for route must be a React component

The component for route 'Feed' must be a React component. I've checked most of the other similar questions here but the majority of them are due to basic syntax (which maybe I have too but am blind to!). I've removed chunks of code that aren't relevant to this issue (navigationOptions and other scre...
illya
1

votes
1

answer
65

Views

React / React Native: can't setState using key from previous state?

Struggling to see what the difference is between these two snippets: State is NOT set handleAddItemToCart = (item) => { this.setState((state) => { const { cartItems } = state; item.quantity = 1; cartItems.push(item); return { cartItems }; }); } State IS set return { cartItems: [...cartItems] } It's...
rubie
1

votes
3

answer
453

Views

Loadash is not validating string Negative values in javascript

I am working on React Native project. And I am getting response from server, And the response is like below. { 'id': 12, 'year': 2019, 'percentage': '-0.45', }, { 'id': 13, 'year': 2018, 'percentage': '4.45', }, So, I have to check either empty or not particular field, If it is empty, I have to set...
1

votes
1

answer
232

Views

React Native Bullet Character?

I want to use Bullet Character/ Small Circles used for passwords in React Native Text component. Is there a way to create them without using package. I am thinking of creating a rounded View with background filled. However, kindly let know if a simpler solution exists.
Rusty
1

votes
1

answer
59

Views

How to show shadow effect on Android (React native)

I'm trying to show the shadow effect in React native app, and the shadow works well for iOS, but not for Android. How can I handle this problem? Here is the code that I am using right now: shadowOffset: { height: 0, width: 0 } shadowOpacity: 0
Naruto
1

votes
1

answer
132

Views

what is function scoped variables (var) and block scoped variables in es6?

I am new to javascipt as I have started learning js now, I am pretty confused with var that is said to be function scoped and block scoped; If so then how do we access them outside of that function!? lets say i want to use it from another class (I don't know maybe by creating some object or whatever...
Imran
1

votes
2

answer
39

Views

React Native: generate release APK using npm command

I am using such command to generate an APK: react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android Is it possible to edit this command to generate rel...
drevival
1

votes
1

answer
47

Views

ReactNative: Dismiss Keyboard on scroll of Multiline TextInput

I'm using a multiline TextInput and I would like to dismiss the keyboard while scrolling using the onScroll() props The Code I tried: this.setState({bodyContent})} value = {this.state.bodyContent} editable = {true} multiline={true} onScroll = {() => Keyboard.dismiss() } /> Also noticed that onScroll...
Jijo Bose

View additional questions