| 1234567891011121314151617181920212223 |
- import * as React from 'react';
- import { useThrottleFn } from '@umijs/hooks';
- import { Text } from 'react-native-magnus';
- import Time from '../Utils/TimeUtils';
- export default function CountDown(props) {
- const { endTime, format, size, color, valueFormat } = props;
- const [value, setValue] = React.useState(
- new Time(endTime, format).getNowTime(valueFormat)
- );
- const { run } = useThrottleFn(() => {
- setValue(new Time(endTime, format).getNowTime(valueFormat));
- setTimeout(() => {
- run();
- }, 500);
- }, 1000);
- run();
- return (
- <Text fontSize={size} color={color}>
- {value}
- </Text>
- );
- }
|