useEnable2fa hook completes 2FA enrollment by verifying the code from the user’s authenticator app. Call it after useSetup2fa has returned the QR code and the user has scanned it.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Hook for enabling two-factor authentication with a verification code
useEnable2fa hook completes 2FA enrollment by verifying the code from the user’s authenticator app. Call it after useSetup2fa has returned the QR code and the user has scanned it.
import { useEnable2fa } from "@getpara/react-native-wallet";
import { useEnable2fa } from "@getpara/react-native-wallet";
import { useState } from "react";
import { View, TextInput, Button } from "react-native";
function Enable2faScreen() {
const [code, setCode] = useState("");
const { enable2faAsync, isPending } = useEnable2fa();
const handleEnable = async () => {
try {
await enable2faAsync({ verificationCode: code });
} catch (err) {
console.error(err);
}
};
return (
<View>
<TextInput value={code} onChangeText={setCode} placeholder="Enter code from app" keyboardType="number-pad" />
<Button title={isPending ? "Enabling..." : "Enable 2FA"} onPress={handleEnable} disabled={isPending} />
</View>
);
}