touchableopacity

How to make TouchableOpacity button to prevent multiple clicks

落花浮王杯 提交于 2021-01-28 10:25:49
问题 I have TouchableOpacity with event that I don't want to execute twice. I tried to put in it's onPress event bool in state but this doesn't work as setting state is async and I can press button multiple times fast. I also tried to set timer but this also doesn't work for me. Is there any other way to prevent multiple press on button (some other similar component etc.)? 回答1: You do not need to setState to store values which do not reflect as UI changes. You could directly have a this.flag

How to make TouchableOpacity button to prevent multiple clicks

霸气de小男生 提交于 2021-01-28 10:25:16
问题 I have TouchableOpacity with event that I don't want to execute twice. I tried to put in it's onPress event bool in state but this doesn't work as setting state is async and I can press button multiple times fast. I also tried to set timer but this also doesn't work for me. Is there any other way to prevent multiple press on button (some other similar component etc.)? 回答1: You do not need to setState to store values which do not reflect as UI changes. You could directly have a this.flag

How to make TouchableOpacity button to prevent multiple clicks

旧时模样 提交于 2021-01-28 10:24:55
问题 I have TouchableOpacity with event that I don't want to execute twice. I tried to put in it's onPress event bool in state but this doesn't work as setting state is async and I can press button multiple times fast. I also tried to set timer but this also doesn't work for me. Is there any other way to prevent multiple press on button (some other similar component etc.)? 回答1: You do not need to setState to store values which do not reflect as UI changes. You could directly have a this.flag

TouchableOpacity swallow touch event and never pass

ⅰ亾dé卋堺 提交于 2021-01-27 22:01:05
问题 I'm trying to make both onPress to happened TouchableOpacity , but the second one is the only one that fires: <TouchableOpacity onPress={() => console.warn('first button')}> <TouchableOpacity onPress={() => console.warn('second button')}> <Text> PRESS ME </Text> </TouchableOpacity> </TouchableOpacity> How can I make both of them fire? Thanks in advance! 回答1: You can fire both of them simply using the 'ref' concept and calling the props onPress. <TouchableOpacity onPress={() => AlertIOS.alert(

TouchableOpacity swallow touch event and never pass

浪子不回头ぞ 提交于 2021-01-27 19:43:00
问题 I'm trying to make both onPress to happened TouchableOpacity , but the second one is the only one that fires: <TouchableOpacity onPress={() => console.warn('first button')}> <TouchableOpacity onPress={() => console.warn('second button')}> <Text> PRESS ME </Text> </TouchableOpacity> </TouchableOpacity> How can I make both of them fire? Thanks in advance! 回答1: You can fire both of them simply using the 'ref' concept and calling the props onPress. <TouchableOpacity onPress={() => AlertIOS.alert(

Stacked TouchableOpacity inside another TouchableOpacity is not clickable

别等时光非礼了梦想. 提交于 2020-07-17 06:18:05
问题 Even though this document (https://facebook.github.io/react-native/docs/gesture-responder-system.html) states, that touch events are passed down to the children and are only consumed by a parent, if the child doesn't react on the event, I face the issue, that a TouchableOpacity nested inside another TouchableOpacity doesn't react properly on touches. My structure is like follows <ScrollView> <TouchableOpacity onPress={() => console.log('This is printed always')}> <View> <Text>I can click here

Delay in tap response when using TransitionPresets

血红的双手。 提交于 2020-03-03 07:29:19
问题 UPDATE: The problem seems to come when I use animation using ...TransitionPresets.SlideFromRightIOS . I have a simple screen where on tapping a touchableOpacity it navigates to another screen with some parameters. The issue is that sometimes I need to tap twice to move to another screen. I am not sure why this happens. DEMO: App.js <SafeAreaProvider> <NavigationContainer> <Stack.Navigator screenOptions={{ headerStyle: { elevation: 0, }, headerTitleStyle: { fontFamily: "Google Sans Regular",

React native TouchableOpacity onPress Problems

老子叫甜甜 提交于 2020-01-13 10:36:26
问题 I have a simple icon button as follows : class SideIcon extends Component { render() { return ( <TouchableOpacity onPress={console.log('puff')} style={styles.burgerButton}> <Icon name="bars" style={styles.burgerIcon}/> </TouchableOpacity> ); } } It's called from the following component : export default test = React.createClass({ getInitialState: function() { return { isModalOpen: false } }, _openModal() { this.setState({ isModalOpen: true }); }, _closeModal() { this.setState({ isModalOpen:

React native navigation is not working on TouchableOpacity

折月煮酒 提交于 2019-12-12 01:48:31
问题 I tried react-native on Button which is working fine. I want to customize Button so this made me to go for TouchableOpacity . I am trying to setup react native navigation like below which is not working now. I am using this for navigation https://reactnavigation.org/ index.android.js /** * https://github.com/facebook/react-native * @flow */ import React, { Component } from "react"; import { AppRegistry, Image, View, Text, Button, StyleSheet, TouchableOpacity } from "react-native"; import {