useUnfollow
useUnfollow
is a React Hook that lets you unfollow a profile.
const { data, loading } = useUnfollow();
Usage
import { ProfileFragment, useUnfollow } from '@lens-protocol/react';
type ProfileUnfollowProps = {
profile: ProfileFragment;
};
export function UnfollowProfile({ profile }: ProfileUnfollowProps) {
const { unfollow, isPending } = useUnfollow({ profile });
if (!profile.isFollowedByMe) {
return null;
}
return (
<button onClick={unfollow} disabled={isPending}>
{isPending ? 'Unfollowing...' : 'Unfollow'}
</button>
);
}
Reference
useUnfollow()
useUnfollow()
Call useUnfollow
where your unfollow button markup is and provide the profile that you would like to unfollow.
type ProfileUnfollowProps = {
profile: ProfileFragment;
};
export function UnfollowProfile({ profile }: ProfileUnfollowProps) {
const { unfollow, isPending } = useUnfollow({ profile });
// ...
}
Parameters
profile: ProfileFragment
: the profile you wish to unfollow
Returns
unfollow
an async function that returns void used to unfollow a profile on button clickisPending
a boolean flag that informs you if an unfollow is in progress
unfollow
function
unfollow
functionThe unfollow
function returned by useUnfollow
allows you to programmatically unfollow a profile, usually in a on click handler of a button. It takes no parameters.
unfollow()
Parameters
unfollow
takes no parameters (the profile is supplied touseUnfollow
directly)
Updated 11 days ago