Use Post Context Hook
A hook for queries and operations in a shared Lens post context
This hook exposes the Post context from LensPostProvider allowing access to the post data and related functionalities within the context of a Lens Post. It is useful for components that need to interact with or display information about a specific Post.
Installation
Usage
This hook can only be used in components that are children of a LensPostProvider
.
import { useLensPostContext } from "@/hooks/use-lens-post-context";
const { post } = useLensPostContext();
API Reference
The return value of the hook is a PostContextType
object:
Prop | Description | Type |
---|---|---|
post | The Post data object. | AnyPost |
loading | A boolean indicating if the post data is currently being loaded. | boolean |
error | An error object if there was an issue fetching the post data. | Error |
optimistic | The local state of Post actions. | OptimisticState |
toggleLike | Toggle the upvote status for the authenticated user. | function |
comment | Create a comment on the Post from the authenticated user. | function |
collect | Collect the Post for the authenticated user. | function |
repost | Repost the post by the authenticated user. | function |
quote | Quote the post by the authenticated user. | function |
tip | Tip the post from the authenticated user. | function |
toggleBookmark | Toggle the bookmark status for the authenticated user. | function |