Skip to main content

Count Down

#CountDown component

The part of the countdown component that calls the backend interface to send the request is implemented by the developer (including mobile phone number verification, etc.).

Effect demonstration

1. Default configuration

import { Form, CountDown, InputItem } from "packages/components";
const { FormItem, useForm } = Form;
const [form] = useForm();

<Form onFinish={handleFinish} form={form}>
<Form.FormListItem
title="Phone number"
required
name="useCharacter"
rules={[
{
required: true,
message: "Please enter your phone number",
},
]}
>
<InputItem
keyboardType="number-pad"
border={false}
placeholder="Please enter your phone number"
inputStyle={{ textAlign: "right" }}
/>
</Form.FormListItem>
<WhiteSpace size="x4" />
<FormItem
type={bordered ? "all" : "bottom"}
name="sms"
rules={[{ required: true, message: "Please enter verification code" }]}
>
<CountDown
bordered={false}
onSend={() => {
// Send code
console.log(form.getFieldValue("useCharacter"));
}}
/>
</FormItem>
<WhiteSpace size="x4" />
<Button title="Login" onPress={() => {}} />
</Form>;

2. Configure codeType

<Form onFinish={handleFinish} form={form}>
<FormListItem
title="Mobile phone number"
required
name="useCharacter"
rules={[
{ required: true, message: "Please enter your mobile phone number" },
]}
>
<InputItem
border={false}
placeholder="Please enter your mobile phone number"
inputStyle={{ textAlign: "right" }}
/>
</FormListItem>
<WhiteSpace size="x4" />
<FormItem
type={bordered ? "all" : "bottom"}
name="sms"
rules={[{ required: true, message: "Please enter the verification code" }]}
>
<CountDown
bordered={bordered}
codeType="border"
onSend={() => {
console.log("123");
}}
/>
</FormItem>
</Form>

API

PropertiesRequiredDescriptionTypeDefault Value
labelfalseCountdown textstringGet verification code
resendLabelfalseResend textstringResend
countfalseCountdown durationnumber60
onBeforefalseCallback before sending verification code() => Promise<boolean>
onSendtrueSend verification code() => void
onEndfalseCallback after countdown ends() => void
borderedfalseWhether to display the outer borderbooleanfalse
codeTypefalseWhether the verification code style has a bordernormal | bordernormal
brieffalseExtrasReactNode
stylefalseInput box custom styleViewStyle
activeOpacityfalseOpacity when pressednumber0.6
placeholderfalsedefault promptstring
leftIconfalseleft iconReactNode
valuefalseVerification code valuestring
onChangefalseInput change event(value: string) => void