useVerify2fa hook verifies a 2FA code as part of the login flow, for users who have 2FA enabled on their account.
Import
import { useVerify2fa } from "@getpara/react-native-wallet";
Usage
import { useVerify2fa } from "@getpara/react-native-wallet";
import { useState } from "react";
import { View, TextInput, Button } from "react-native";
function Verify2faScreen({ userEmail }: { userEmail: string }) {
const [code, setCode] = useState("");
const { verify2faAsync, isPending } = useVerify2fa();
const handleVerify = async () => {
try {
await verify2faAsync({
auth: { email: userEmail },
verificationCode: code,
});
} catch (err) {
console.error(err);
}
};
return (
<View>
<TextInput value={code} onChangeText={setCode} placeholder="Enter 2FA code" keyboardType="number-pad" />
<Button title={isPending ? "Verifying..." : "Verify"} onPress={handleVerify} disabled={isPending} />
</View>
);
}