Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

count down timer in react native

// isResendEnable is just my custom variable to check if i have enabled 
// resend function in my otp box
  const [timerCount, setTimer] = useState(20);
  const [activator, setActivator] = useState(Math.random());
  useEffect(() => {
    let interval;
    if (isResendEnable) {
      interval = setInterval(() => {
        if (timerCount > 0) {
          setTimer(lastTimerCount => {
            lastTimerCount <= 1 && clearInterval(interval);
            return lastTimerCount - 1;
          });
        }
      }, 1000);
    }

    return () => {
      if (isResendEnable) {
        clearInterval(interval);
      }
    };
  }, [activator]);
  
  return <Text> Resend in {timerCount} sec </Text>
Comment

react native countdown

import CountDown from 'react-native-countdown-component'; render() {    return (      <CountDown        size={30}        until={1000}        onFinish={() => alert('Finished')}        digitStyle={{backgroundColor: '#FFF', borderWidth: 2, borderColor: '#1CC625'}}        digitTxtStyle={{color: '#1CC625'}}        timeLabelStyle={{color: 'red', fontWeight: 'bold'}}        separatorStyle={{color: '#1CC625'}}        timeToShow={['H', 'M', 'S']}        timeLabels={{m: null, s: null}}        showSeparator      />    )}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery set select value 
Javascript :: javascript object to array 
Javascript :: how to access dictionary keys in js 
Javascript :: font awesome cdn svg with js 
Javascript :: javascript set input value 
Javascript :: add table row jquery 
Javascript :: add array to array javascript 
Javascript :: js read xml file 
Javascript :: react native webview not working 
Javascript :: make multiple array in one array 
Javascript :: stop a site from reloading javascript 
Javascript :: jquery get duration video tag 
Javascript :: react-native navigation screen props 
Javascript :: adb reverse USB debugging 
Javascript :: countdown timer javascript stack overflow 
Javascript :: empty function after it is run javascript 
Javascript :: selector id jquery but is variable 
Javascript :: stream recording javascript 
Javascript :: ajax select2 
Javascript :: number to array js 
Javascript :: javascript edit form value 
Javascript :: reset select option jquery 
Javascript :: mongoose unique validator 
Javascript :: deploy vue js to shared hosting 
Javascript :: check Browser version js 
Javascript :: sorting in javascript 
Javascript :: how to make fake binary 
Javascript :: javascript move element to coordinates 
Javascript :: how to play audio in javascript 
Javascript :: webpack error cannot find module 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =