倒计时hooks

更新时间:2021-08-10 01:59:41下载pdf

useCountDown

Hooks 描述

用于快速实现倒计时,常用在开始运动倒计时页面。

使用示例

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { Utils, TYText } from 'tuya-panel-kit';
import { hooks } from '@tuya/tuya-panel-health-sdk';
import Section from '../Section';

const { useCountDown } = hooks;

const { convertX: cx } = Utils.RatioUtils;

const CountDown = () => {
  const onEnd = () => {
    console.log('countdown end');
  };

  const [countdown] = useCountDown({
    targetCount: 3000,
    onEnd: onEnd,
  });

  return (
    <View style={{ flex: 1, padding: cx(20) }}>
      <Section title={getLang('dsc_default')}>
        <TYText>{countdown}</TYText>
      </Section>
    </View>
  );
};
export default CountDown;

const styles = StyleSheet.create({});