useCreatePost
Introduction
The useCreatePost
hook is a custom hook that provides functionality to create a new post in the feed. It handles the state and logics and functions required to create or edit a post. This hook simplifies the process of creating custom UI for post creation and editing.
The useCreatePost
hook returns the following properties.
Property | Type | Description |
---|---|---|
postText | string | null | The text content of the post. |
setPostText | (text: string) => void | Function to set the text content of the post. |
question | string | null | The question content of the post. |
setQuestionText | (text: string) => void | Function to set the question content of the post. |
mediaList | File[] | List of media files attached to the post. |
addMediaItem | (event: React.ChangeEvent<HTMLInputElement>) => void | Function to add a media item to the post. |
removeMedia | (index: number) => void | Function to remove a media item from the post by index. |
clearMedia | () => void | Function to clear all media items from the post. |
mediaUploadMode | LMFeedCreatePostMediaUploadMode | The mode of media upload for the post. |
changeMediaUploadMode | (mode: LMFeedCreatePostMediaUploadMode) => void | Function to change the media upload mode. |
textFieldRef | MutableRefObject<HTMLDivElement | null> | Reference to the text field element. |
containerRef | MutableRefObject<HTMLDivElement | null> | Reference to the container element. |
postFeed | () => Promise<void> | Function to post the feed. |
editPost | () => Promise<void> | Function to edit the post. |
ogTag | OgTag | null | Open Graph tag information for the post. |
openCreatePostDialog | boolean | Flag indicating if the create post dialog is open. |
setOpenCreatePostDialog | React.Dispatch<boolean> | Function to set the open state of the create post dialog. |
temporaryPost | Post | null | Temporary post data. |
clearPollFunction | () => void | Function to clear the poll. |
editPollFunction | () => void | Function to edit the poll. |
selectedTopicIds | string[] | List of selected topic IDs for the post. |
setSelectedTopicIds | React.Dispatch<string[]> | Function to set the selected topic IDs. |
preSelectedTopics | Topic[] | List of preselected topics for the post. |
setPreSelectedTopics | React.Dispatch<Topic[]> | Function to set the preselected topics. |
showOGTagViewContainer | boolean | Flag indicating if the OG tag view container is shown. |
closeOGTagContainer | () => void | Function to close the OG tag container. |
removeThumbnailReel | () => void | Function to remove the thumbnail reel. |
removeAddReel | () => void | Function to remove the added reel. |
createPostComponentClickCustomCallback | ComponentDelegatorListener | undefined | Optional custom callback for component click events. |
addThumbnailReel | (event: React.ChangeEvent<HTMLInputElement>) => void | Function to add a thumbnail reel. |
addReel | (event: React.ChangeEvent<HTMLInputElement>) => void | Function to add a reel. |
tempReel | File[] | List of temporary reel files. |
tempReelThumbnail | File[] | List of temporary reel thumbnail files. |
isAnonymousPost | boolean | Flag indicating if the post is anonymous. |
changeAnonymousPostStatus | () => void | Function to change the anonymous post status. |
openCreatePollDialog | boolean | Flag indicating if the create poll dialog is open. |
setOpenCreatePollDialog | React.Dispatch<boolean> | Function to set the open state of the create poll dialog. |
pollOptions | PollOption[] | List of poll options. |
addPollOption | ZeroArgVoidReturns | Function to add a poll option. |
updatePollOption | TwoArgVoidReturns<string, number> | Function to update a poll option. |
removePollOption | OneArgVoidReturns<number> | Function to remove a poll option. |
changePollText | OneArgVoidReturns<React.ChangeEvent<HTMLTextAreaElement>> | Function to change the poll text. |
pollText | string | The text content of the poll. |
updatePollExpirationDate | OneArgVoidReturns<number | null> | Function to update the poll expiration date. |
pollExpirationDate | number | null | The expiration date of the poll. |
advancedOptions | AdvancedPollOptions | The advanced options for the poll. |
validatePoll | boolean | Flag indicating if the poll validation is enabled. |
previewPoll | boolean | Flag indicating if the poll preview is shown. |
setPreviewPoll | React.Dispatch<boolean> | Function to set the poll preview state. |
updateAdvancedOptions | OneArgVoidReturns <React.ChangeEvent<HTMLInputElement> | SelectChangeEvent<number> > | Function to update advanced poll options. |
pollExpiryTimeClickFunction | () => void | Function to handle poll expiry time click event. |
Example
For example implementation, checkout here