メインコンテンツへスキップ
useResend(options?)
この React フックは、ACUL の画面における検証コードの再送信などの「再送信」アクションを管理します。このフックは次のことを行います:
  • クールダウンの残り時間を追跡します。
  • 再送信ボタンを無効にすべきかどうかを示します。
  • 即座に再送信を開始するための startResend 関数を提供します。

Parameters

options
timeoutSecondsonTimeout などを指定するための省略可能な設定です。

Returns

UseResendReturn次のプロパティを持つオブジェクトです:
  • remaining — 次に再送信が許可されるまでに残っている秒数。
  • disabled — 現在再送信がブロックされている場合は true
  • startResend — (許可されていれば)すぐに再送信を開始するために呼び出します。

Supported Screens

  • email-identifier-challenge
  • email-otp-challenge
  • login-email-verification
  • login-passwordless-email-code
  • login-passwordless-sms-otp
  • mfa-email-challenge
  • mfa-sms-challenge
  • mfa-voice-challenge
  • phone-identifier-challenge
  • reset-password-mfa-email-challenge
  • reset-password-mfa-sms-challenge
  • reset-password-mfa-voice-challenge
Example
import { useResend } from '@auth0/auth0-acul-react/mfa-sms-challenge';

export function ResendButton() {
  const { remaining, disabled, startResend } = useResend({
    timeoutSeconds: 30,
    onTimeout: () => console.log('You can resend again'),
  });

  return (
    <button onClick={startResend} disabled={disabled}>
      {disabled ? `Resend in ${remaining}s` : 'Resend Code'}
    </button>
  );
}

Remarks

  • 内部で使用される ResendControl には明示的な終了メソッドがなく、このフックに対して手動のクリーンアップ処理は不要です。
  • timeoutSeconds または onTimeout が変更されると、フックは再送信マネージャーを再初期化します。