• Preparing search index...
  • The search index is not available
Lens SDK Reference
  • Lens SDK Reference
  • @lens-protocol/react-web
  • Core
  • useLazyPublication

Function useLazyPublication

  • useLazyPublication(): UseDeferredTask<AnyPublication, NotFoundError | UnspecifiedError, FetchPublicationArgs>
  • Experimental

    useLazyPublication is a lazy version of usePublication React Hook.

    This hook will not fetch the publication until the returned function is called.

    This hook is intended to enable more complex use cases, the vast majority of use cases should use usePublication instead.

    Returns UseDeferredTask<AnyPublication, NotFoundError | UnspecifiedError, FetchPublicationArgs>

    Example

    const { called, data, error, loading, execute } = useLazyPublication();
    

    This hook is experimental and may change in the future.

    const { called, data, error, loading, execute } = useLazyPublication();

    const callback = async () => {
    const result = await execute({ forId: publicationId });

    if (result.isFailure()) {
    toast.error(result.error.message);
    return;
    }

    const publication = result.value;

    // do something with the publication
    }
    • Defined in packages/react/src/publication/useLazyPublication.ts:54

Settings

Member Visibility

Theme

Lens SDK Reference
  • @lens-protocol/react-web - v2.3.2
  • @lens-protocol/react-native - v2.3.2
  • @lens-protocol/client - v2.3.2