useLogout hook logs out the current user and clears their session. Optionally clears any pregenerated wallets stored for the user.
Hook for logging out the current user
useLogout hook logs out the current user and clears their session. Optionally clears any pregenerated wallets stored for the user.
import { useLogout } from "@getpara/react-native-wallet";
import { useLogout } from "@getpara/react-native-wallet";
import { Alert, Button } from "react-native";
function LogoutButton() {
const { logoutAsync, isPending } = useLogout();
const handleLogout = () => {
Alert.alert("Sign Out", "Are you sure you want to sign out?", [
{ text: "Cancel", style: "cancel" },
{
text: "Sign Out",
style: "destructive",
onPress: async () => {
try {
await logoutAsync({});
} catch (err) {
console.error(err);
}
},
},
]);
};
return <Button title={isPending ? "Signing out..." : "Sign Out"} onPress={handleLogout} disabled={isPending} />;
}