Use Reaction Toggle Hook
A hook to toggle reactions (like/unlike) on Lens publications using the Lens React SDK.
This hook toggles the upvote reaction on a given post. It checks if the authenticated user has already upvoted the post and either adds or removes the upvote accordingly.
Installation
Usage
import { useReactionToggle } from "@/hooks/use-reaction-toggle";
import { usePost, useSessionClient } from "@lens-protocol/react";
const { execute: toggleReaction } = useReactionToggle();
const { data: session } = useSessionClient();
const { data: post } = usePost({ post: "SOME_ID_OR_SLUG" });
const res = await toggleReaction({ post, session });
if (res.isErr()) {
// Handle error
} else {
// Reaction toggled successfully
}