UNPKG

@lens-protocol/react

Version:

Interacting with the Lens Protocol API using React.

81 lines (80 loc) 2.09 kB
import { FeedItem, FeedRequest, FeedWhere } from '@lens-protocol/api-bindings'; import { PaginatedArgs, PaginatedReadResult } from "../helpers/reads.js"; import { SuspenseEnabled, SuspensePaginatedResult } from "../helpers/suspense.js"; /** * {@link useFeed} hook arguments */ export type UseFeedArgs = PaginatedArgs<FeedRequest>; export type { FeedRequest, FeedWhere }; /** * {@link useFeed} hook arguments with Suspense support * * @experimental This API can change without notice */ export type UseSuspenseFeedArgs = SuspenseEnabled<UseFeedArgs>; /** * Fetch a the feed of a given profile and filters. * * You MUST be authenticated via {@link useLogin} to use this hook. * * @example * ```tsx * const { data, loading, error } = useFeed({ * where: { * for: '0x01`, // profileId * }, * }); * * if (loading) return <div>Loading...</div>; * * if (error) return <div>Error: {error.message}</div>; * * return ( * <ul> * {data.map((item, idx) => ( * <li key={`${item.root.id}-${idx}`}> * // render item details * </li> * ))} * </ul> * ); * ``` * * @category Discovery * @group Hooks * @param args - {@link UseFeedArgs} */ export declare function useFeed({ where }: UseFeedArgs): PaginatedReadResult<FeedItem[]>; /** * Fetch a the feed of a given profile and filters. * * You MUST be authenticated via {@link useLogin} to use this hook. * * This signature supports [React Suspense](https://react.dev/reference/react/Suspense). * * @example * ```tsx * const { data, loading, error } = useFeed({ * where: { * for: '0x01`, // profileId * }, * suspense: true, * }); * * return ( * <ul> * {data.map((item, idx) => ( * <li key={`${item.root.id}-${idx}`}> * // render item details * </li> * ))} * </ul> * ); * ``` * * @experimental This API can change without notice * @category Discovery * @group Hooks * @param args - {@link UseSuspenseFeedArgs} */ export declare function useFeed({ where }: UseSuspenseFeedArgs): SuspensePaginatedResult<FeedItem[]>;