react-native

fetching data from API in react poll

可紊 提交于 2021-02-11 12:28:07
问题 I want to fetch data from API and show frontend using react but I am getting error from frontend side which is (TypeError: answers.map is not a function ) so how can I solve this error -- MY CODE IS - import React, { useState, useEffect } from "react"; import Poll from "react-polls"; import { getPolls } from "../helper/coreapicalls"; const MainPoll = () => { const [polls, setPoll] = useState([]); const [error, seterror] = useState(false); // Setting answers to state to reload the component

Css Properties and TextStyle Types

别来无恙 提交于 2021-02-11 12:27:29
问题 I have a textStyle which is a type of TextStyle (it comes from react-native types) or React.CSSProperties. I want to pass this type to style attribute for html span element. style attribute accepts type of React.CSSProperties. My interface and span element is: export interface IBaseTextStyleType { textStyle: React.CSSProperties | TextStyle } <span style={style.textStyle}> {this.props.children || this.props.text} </span> I got this error in style of span: Type 'CSSProperties | TextStyle' is

Css Properties and TextStyle Types

此生再无相见时 提交于 2021-02-11 12:25:31
问题 I have a textStyle which is a type of TextStyle (it comes from react-native types) or React.CSSProperties. I want to pass this type to style attribute for html span element. style attribute accepts type of React.CSSProperties. My interface and span element is: export interface IBaseTextStyleType { textStyle: React.CSSProperties | TextStyle } <span style={style.textStyle}> {this.props.children || this.props.text} </span> I got this error in style of span: Type 'CSSProperties | TextStyle' is

how to render data fecthed from firebase database in react-native functional components

戏子无情 提交于 2021-02-11 12:22:46
问题 I'm getting data from firebase databse in console that look like this. [{ "isDonor": true, "name": "Nadi", "photo": "https://gre", "uid": "2ZE" }, { "email": "mmaz", "isDonor": true, "name": "Mz", "photo": "https://gra", "uid": "Cb" }] I want to create cards of each objects but how to accomplish that as data is fetched after some time? I want to render it like this Ihave checked other answres but they are mostly from class component. I have tried using useEffect hook but couldn't implement it

How to store API data in app after login into an app and use it after in another screen in react native

那年仲夏 提交于 2021-02-11 12:20:40
问题 I am new to react native. I have created An app. In this app when User login he get a data through API. for example = userID = 1, userName = abc. so I want to save that data in session storage or local storage in app. and I want to use it after for posting my form data to server. for example when user looged in he get ID that is 1 and when It goes to Form screen and submit the form then. I want to send that userID through API to server means in database. here is my login screen import React,

How to navigate in a screen which is not defined because of a variable?

人盡茶涼 提交于 2021-02-11 12:19:21
问题 When I am in the login screen I would like once the user logs in that it is also redirected to the 'Home' screen but currently, I have an error telling me that the Home is not defined what is normal ... {isAuth ? ( <BottomTab.Screen name='Home' component={Home} /> ): ( <> <BottomTab.Screen name='Connexion' component={Login} /> <BottomTab.Screen name='Inscription' component={Register} /> </> I don't really know how to use contexts yet but I think it might simplify the thing but in the meantime

How can I import OpenCV library to React-Native project

无人久伴 提交于 2021-02-11 12:19:16
问题 I tried to import OpenCV via native code but that not worked and I also tried react-native-opencv library but that library doesn't contain all OpenCV methods. How can I achieve to use OpenCV in my react-native project? Thanks in advance. 回答1: I have been struggling with OpenCV in react-native for a week now and finally got it working. There is this very good article https://brainhub.eu/blog/opencv-react-native-image-processing/ together with this repo https://github.com/brainhubeu/react

React Native: Make Each Child of ScrollView Full Height

余生长醉 提交于 2021-02-11 12:14:27
问题 I have a ScrollView which has two children, and I want each of the children to be the full height of the available space on the screen, meaning view 1 fills the whole screen, and then I scroll down to start to see part of slide 2. If I scroll all the way down, I should only see slide 2. I can't figure out how to get this to happen. What is currently happening is that each child is filling half of the available vertical space, so I don't get any scrolling. Any ideas how I can achieve this

My mapStateToProps is not called after adding custom object array to redux state

大憨熊 提交于 2021-02-11 12:10:47
问题 I am trying for few hours but can't figure out why my state is not called after adding an array of custom object . // In my component... const myRemoteArray = getRemoteArray() // Is working props.addAdItems(myRemoteArray) // Calls **1 via component.props /// ... const mapDispatchToProps = (dispatch) => { return { addAdItems: (items) => { // **1 // Items contains my array of objects dispatch(addAdItems(items)) // Calls **2 }, } } // My action export const addAdItems = (items) => { // **2 //

React Native Push Notification Not Working Properly

北战南征 提交于 2021-02-11 12:03:33
问题 Push Notification function: PushNotification.configure({ largeIcon: "ic_launcher", smallIcon: "ic_notification", onNotification: function (notification) { PushNotification.localNotification({ autoCancel: true, message: 'Test Message', title: 'Test Message', vibrate: true, vibration: 300, playSound: true, soundName: 'default' }) console.log(notification) }, }); Problem: When I run application, if I send notification from php server I am getting response in console.log but condition 1: