UNPKG

@lens-protocol/react

Version:

Interacting with the Lens Protocol API using React.

65 lines (64 loc) 2.07 kB
import { ExplorePublication, ExplorePublicationRequest, ExplorePublicationsWhere } from '@lens-protocol/api-bindings'; import { PaginatedArgs, PaginatedReadResult } from "../helpers/reads.js"; import { SuspenseEnabled, SuspensePaginatedResult } from "../helpers/suspense.js"; /** * {@link useExplorePublications} hook arguments */ export type UseExplorePublicationsArgs = PaginatedArgs<ExplorePublicationRequest>; export type { ExplorePublicationRequest, ExplorePublicationsWhere }; /** * {@link useExplorePublications} hook arguments with Suspense support * * @experimental This API can change without notice */ export type UseSuspenseExplorePublicationsArgs = SuspenseEnabled<UseExplorePublicationsArgs>; /** * Discover new publications base on a defined criteria. * * ```tsx * const { data, error, loading } = useExplorePublications( * where: { * publicationTypes: [ExplorePublicationType.Post], * }, * orderBy: ExplorePublicationsOrderByType.TopCommented, * ); * * if (loading) return <Loader />; * * if (error) return <Error message={error.message} />; * * return ( * <> * {data.map((publication) => ( * <PublicationCard key={publication.id} publication={publication} /> * ))} * </> * ); * ``` * * @category Discovery * @group Hooks */ export declare function useExplorePublications(args?: UseExplorePublicationsArgs): PaginatedReadResult<ExplorePublication[]>; /** * Discover new publications base on a defined criteria. * * This signature supports [React Suspense](https://react.dev/reference/react/Suspense). * * ```ts * const { data } = useExplorePublications( * where: { * publicationTypes: [ExplorePublicationType.Post], * }, * orderBy: ExplorePublicationsOrderByType.TopCommented, * suspense: true, * ); * * console.log(data); * ``` * * @experimental This API can change without notice * @category Discovery * @group Hooks */ export declare function useExplorePublications(args: UseSuspenseExplorePublicationsArgs): SuspensePaginatedResult<ExplorePublication[]>;