• useReactionToggle hook allows to add or remove a reaction to a publication.

    You MUST be authenticated via useLogin to use this hook.

    Returns UseDeferredTask<void, never, ReactionToggleArgs>

    Example

    import { PrimaryPublication, useReactionToggle } from '@lens-protocol/react-web';

    function Publication({ publication }: { publication: PrimaryPublication }) {
    const { execute: toggle, loading, error } = useReactionToggle();

    const toggleReaction = async () => {
    await toggle({
    reaction: PublicationReactionType.Upvote,
    publication,
    });
    };

    if (error) {
    return <p>Error reacting to publication: {error.message}</p>;
    }

    return (
    <div>
    // render publication details
    <button onClick={toggleReaction} disabled={loading}>
    Toggle reaction
    </button>
    </div>
    );
    }