@td-design/rn-hooks
Version:
从ahooks里面抽取的一些在rn项目里可以使用的hooks。提高开发效率
28 lines (27 loc) • 978 B
TypeScript
import { ForwardedRef } from 'react';
import { TextInput } from 'react-native';
interface Props {
/** 倒计时时长,默认为 60s */
count?: number;
/** 倒计时文字,默认为:获取验证码 */
defaultLabel?: string;
/** 重新发送文字,默认为:重新发送 */
resendLabel?: string;
/** 发送之前执行的函数,结果将决定验证码是否允许发送。通常用在验证码发送之前的手机号校验的场景 */
onBefore?: () => Promise<boolean>;
/** 发送验证码 */
onSend: (...args: any[]) => void;
/** 倒计时结束之后执行的函数 */
onAfter?: () => void;
ref?: ForwardedRef<TextInput>;
}
/**
* 用于发送手机验证码的 hook。
* @param props 参数
*/
export default function useSms({ defaultLabel, resendLabel, count, onBefore, onSend, onAfter, ref, }: Props): {
text: string;
disabled: boolean;
sendSms: (...args: any[]) => Promise<void>;
};
export {};