Ways to turn off the touchable opacity功能

Is there a way to temporarily disable a touchable opacity for a minute after it is pressed?

let enable = true;
<TouchableOpacity
     style={styles.btnSolid}
     onPress={() => {
        resetUserPswd(auth, Email, navigation);
        enable = false;
        setTimeout(() => (enable = true), 60000); // 60 seconds
     }}
     disabled={!enable}
>
    <Text style={styles.btnTextSolid}>Send Email</Text>
</TouchableOpacity>

Thank you in advance.

Answer №1

Implement setTimeout in your code as shown below:

  import { useEffect, useState } from 'react';
  
  const [isChecked, setIsChecked] = useState(false);
  const [isClicked, setIsClicked] = useState(false);

  useEffect(() => {
    if (isChecked || !isClicked) {
       return;
    }
    const timer = setTimeout(() => {
      setIsChecked(true);
    }, 60000);
    return () => clearTimeout(timer);
  }, [isClicked]);
  
  <TouchableOpacity
    style={styles.btnSolid}
    onPress={() => {
      resetPassword(auth, email, navigation);
      setIsClicked(true);
    }}
    disabled = {isChecked}
  >
    <Text style={styles.btnTextSolid}>Reset Password</Text>
  </TouchableOpacity>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for transforming typed words into fun emoji characters

Recently, I was working on a social networking application using Angular technology. In order to enhance some of the main features of the application, like those listed below, I utilized the free version of CKEditor. Development of a new post component ...

Retrieve the title and display it as a caption using JavaScript

Below is a snippet of code that takes the title from an element with the class a.preview, appends it to another element with the ID p#preview, and generates some AJAX content on hover. While the title is printing elsewhere, the variable c in this script ...

Utilize Office Scripts to update values across numerous worksheets

Looking for ways to improve the performance of this script, as it currently takes 45 seconds to run. Any ideas? function main(workbook: ExcelScript.Workbook) { try { const sheets = workbook.getWorksheets(); for (let sheet of sheets) { const break ...

Enhance Your Jekyll Site with the Minimal Mistakes Theme Plugin

Hi there! I'm relatively new to website programming and could really use some assistance. I've been attempting to integrate the jekyll-lunr-js-search (https://github.com/slashdotdash/jekyll-lunr-js-search) into the minimal-mistakes theme, but I&a ...

Angular 2 TypeScript: Accelerating the Increment Number Speed

I'm working with a function in Angular 4 that is triggered when the arrow down key is pressed. Each time the arrow down key is hit, the counter increments by 1. In this function, I need to run another function if the counter reaches a certain speed. ...

Maintain checkbox selection even after the page is refreshed

Having trouble fetching all objects from the favorites array and setting the checkbox to checked. I've attempted using localStorage but the values are not saved after refreshing, despite researching online for solutions. Any assistance would be great ...

Invalidating the express response object due to a TypeError issue

Currently, I am in the process of writing a test that utilizes sinon and sinon-express-mock to mock an incorrect request. The goal is to then call a validation function within my application and verify that it returns the expected response status code (400 ...

Obtaining the count of a specific column in Angular 6 by grouping objects based on the same value in an array

In TypeScript, I have an array of objects and I am using a foreach loop. The array contains 2 columns with a progress value of 100, while the rest have values less than 100. My goal is to calculate the count of columns with a progress value of 100, which ...

Is it possible to open a PDF file in a new tab using Angular 4?

When attempting to open a PDF file using the window.open() function, I encountered an issue where the window would open and close automatically, causing the file to be downloaded rather than displayed in a new tab. Despite not having any ad blockers inst ...

Interacting with icons using TouchableOpacity and onPress functionality

I am attempting to implement onPress functionality for icons using TouchableOpacity. However, when I click on the icon, nothing happens and there are no console logs displayed. I have also tried enclosing the icon within an additional View, but that appro ...

How can you prompt a component again in React Native after a specified number of days have passed?

I am currently working on a component that requests app permissions from the user. This component gives the user the option to either accept the permissions or choose "Later". If the user selects "Later", I want the component to prompt again after specific ...

Problem with JavaScript regular expressions and enumeration

Hello there! I'm facing a challenge on how to transform my text using ul and li tags. Let me explain: let text = "You are the best person"; I want to change the "the best person" part into: <ul> <li>the</li> <li>b ...

Using this.forceUpdate to efficiently update state within React-Router-DOM's Link component

I was able to resolve my issue on my own, but I'm still unsure about what exactly is going on and why it's working. The situation involves a Link component that links to the current page for a different product. Essentially, it's the same c ...

CSS Gallery Indicator: Enhancing Your Website's Visual Appeal

After implementing a CSS gallery template into my HTML code, I faced an issue. The original code contained only 4 images, but after adding nine more images, the indicator in the gallery stopped moving past the 4th image and the preview of the additional im ...

Submitting an HTML form with no input data

Looking to dynamically pass arguments between pages using the code below: <script type="text/javascript> function buildAndSubmitForm(index){ <? $args = 't='.$team.'&s='.$season.'&l='.$league.&apo ...

What is the best way to access the items generated within a v-for loop?

Currently running a little experiment as I dive into VueJS. My main query revolves around how to access the marker object generated through the v-for loop. <gmap-marker :key="index" v-for="(m, index) in markers" :icon="m.icon" : ...

How about this sentence: "Automatically select a radio button after verifying the associated sentence (label)

Having a bit of trouble... I'm looking to automatically click a radio button...but also need to verify the corresponding sentence (label)... eg...() <-radio button <label>What is 1+1?</label><br/> <input type="radio" name="gro ...

The Angular project failed to run properly following the ng build command

Just started working with Angularjs 2 and encountered an issue after running ng build. The compiled files were placed in the dist folder, but when I checked the index.html file within that folder, all the scripts had missing references even though they w ...

Utilize the split functionality only when the character you want to split by is found in

Consider the following situation: I have 6 string variables that contain special characters. I stored these 6 strings in an array like this: arr=[str1,str2,str3...); arr=escape(arr); due to the presence of special characters in some string variables. ...

Achieve the central element while scrolling on the window

What am I doing wrong? I've been attempting to target the #second element on scroll Here is an example with console.log CODEPEN EXAMPLE $(window).scroll(function(){ var section = $("#second").offset().left, scrollXpos = $( ...