@lens-protocol/react
Version:
Interacting with the Lens Protocol API using React.
33 lines (32 loc) • 1.11 kB
TypeScript
import { AnyPublication } from '@lens-protocol/api-bindings';
import { UseDeferredTask } from "../helpers/tasks.js";
export type UseBookmarkToggleArgs = {
publication: AnyPublication;
};
/**
* `useBookmarkToggle` hook lets the user save or remove a publication from their bookmarks.
*
* You MUST be authenticated via {@link useLogin} to use this hook.
*
* You can use the `primaryPublication.operations.hasBookmarked` property to determine
* if the publication is bookmarked by the active profile.
*
* @category Publications
* @group Hooks
*
* @example
* ```tsx
* import { AnyPublication, useBookmarkToggle } from '@lens-protocol/react-web';
*
* function Publication({ publication }: { publication: AnyPublication }) {
* const { execute: toggle, loading } = useBookmarkToggle();
*
* return (
* <button onClick={() => toggle({ publication })} disabled={loading}>
* {publication.operations.hasBookmarked ? 'Bookmarked' : 'Not bookmarked'}
* </button>
* );
* }
* ```
*/
export declare function useBookmarkToggle(): UseDeferredTask<void, never, UseBookmarkToggleArgs>;