react-native

How to find difference between time in moment.js in React Native

孤街浪徒 提交于 2021-02-11 15:11:38
问题 How can I find difference time in React Native (I'm using moment): Like: let end = endTime; // 10:10:05 let start = startTime; // 10:10:03 moment.utc(moment(end," hh:mm:ss").diff(moment(start," hh:mm:ss"))).format("mm:ss") //expected output: 00:00:02 回答1: You would need to use moment.duration function timeRemaining (start, end) { // get unix seconds const began = moment(start).unix(); const stopped = moment(end).unix(); // find difference between unix seconds const difference = stopped -

How to make a two column grid on react native?

邮差的信 提交于 2021-02-11 15:11:21
问题 I am tasked right now with making a screen that gives options in a grid of two columns with multiple cards as the items of a list. (You can see here) I was trying to create a row flexbox, but it ended up simply continuing horizontally forever. I'd like to know what would be a good way to get this effect os two columns expanding downwards. 回答1: You should use FlatList and set numColumns prop to "2" to show FlatList as grid Here is complete code sample import React from "react"; import {

'sh' is not recognized as an internal or external command

我的未来我决定 提交于 2021-02-11 15:08:32
问题 Creating a new React app in E:\rn-starter\my-app. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template... 'sh' is not recognized as an internal or external command, operable program or batch file. Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed. Deleting generated file... package.json Deleting my-app/ from E:\rn-starter Done. This error pops-up

How to Validate All Input On Single Submit Click In React Native

人走茶凉 提交于 2021-02-11 14:55:28
问题 I am New to react native. I want to Validate multiple InputText on Single Submit click. for example : Mobile Number = must 10 digit should Not start with 0, and Must start With 98 IFSC Code = First Four character must be Alphabet 5th character must be 0, Email Id validation. Please If Possible Modify My code Please Help Me. Thanks ! here is my code import React, {useState, Component} from 'react'; import {Picker, Text, StyleSheet, View, TextInput, Button, KeyboardAvoidingView, ScrollView,

React Native Async Storage set item function

廉价感情. 提交于 2021-02-11 14:54:47
问题 I am using async storage in my items listing app. The problem i am facing is that, my first item does not get stored in the async till i enter the second item. i am saving array of objects with the help of react hooks E.g if I enter items as 1)Apples 2)Bananas then only apples will get saved in the async while bananas will not be saved until i enter the third item. const [getWant, setwant] = useState([]); const saveData = async () => { AsyncStorage.clear() try { await AsyncStorage.setItem("

undefined is not an object evaluating '_ usecontext.user'

廉价感情. 提交于 2021-02-11 14:53:27
问题 I am getting this error in a big react native app. Actually I am running this on expo. Can anyone see through and suggest a solution.Please Help "undefined is not an object evaluating '_ usecontext.user'" import React, { useState } from "react"; import { StyleSheet, Image } from "react-native"; import * as Yup from "yup"; import Screen from "../components/Screen"; import { ErrorMessage, Form, FormField, SubmitButton, } from "../components/forms"; import authApi from "../api/auth"; import

Texts component beside each in Flatlist react native

假装没事ソ 提交于 2021-02-11 14:39:37
问题 I have an array every item in the array have a text and button URL I want to add this texts beside each other Using flatlist this is my code <FlatList data={data.ayahs} keyExtractor={(item, index) => index.toString()} numColumns= '10' columnWrapperStyle={{ flexWrap: 'wrap', flex: 1}} renderItem={this._renderItem.bind(this)} contentContainerStyle= {{justifyContent: 'center'}} /> Actual behavior Expected behavior all texts beside each other It's possible to do that with flatlist? 来源: https:/

undefined is not an object (evaluating 'navigation.navigate'), Cant render properly in react native

余生长醉 提交于 2021-02-11 14:31:03
问题 I have Two files "Browse.js" and "Setting.js" I have render MY complete Browse Screen in "Setting.js" like this function NotificationsScreen({ navigation }) { return ( <Browse /> ); } this is working its rendering But problem is that, when I click on Specific tab Then got this error = undefined is not an object (evaluating 'navigation.navigate') this is my Browse.js import React, { Component } from "react"; import { Dimensions, Image, StyleSheet, ScrollView, TouchableOpacity, View, } from

how to create a drawer using React Native?

假装没事ソ 提交于 2021-02-11 14:25:11
问题 I want to create a drawer that appears only on my homescreen, had tried using React Native side menu but that just hides the drawer behind then tried using createdrawernavigator but I have a bottomtabnavigator inside stacknavigator, and am stuck on how to implement drawer navigator on top of that below is my navigation.js const RootStack = createStackNavigator(); const Tab = createBottomTabNavigator(); const AuthStack = createStackNavigator(); // const Drawer = createDrawerNavigator();

Dynamically navigating between stacks with react-navigation 5

依然范特西╮ 提交于 2021-02-11 14:22:47
问题 I'm trying to dynamically navigate between stacks via a single fetch from a server, which reads a token from the device, and makes a server request to update isUserExists. if isUserExists is false, render AuthStack, otherwise render AppStack. My code: Example for AuthStack.js : import React from "react"; import { createStackNavigator } from "@react-navigation/stack"; import { Auth, Registration, Login, VerifyAuth } from "../../screens/auth"; const Stack = createStackNavigator(); const