useInput
Introduction
The useInput
hook is used to implement the input text field for the chatrooms. You can use this to create your own custom UI for input-field. It returns the following values.
Property | Type | Description | Optional |
---|---|---|---|
inputBoxRef | MutableRefObject<HTMLDivElement | null> | Reference to the input box element. | |
inputWrapperRef | MutableRefObject<HTMLDivElement | null> | Reference to the input wrapper element. | |
inputText | string | The current text in the input field. | |
matchedTagMembersList | Member[] | List of members matching the tagging input. | |
fetchMoreTags | boolean | Indicates whether more tag suggestions need to be fetched. | |
imagesAndVideosMediaList | File[] | null | List of image and video files selected. | ✅ |
documentsMediaList | File[] | null | List of document files selected. | ✅ |
ogTag | OgTag | null | Open Graph (OG) tag metadata, if present. | ✅ |
gifMedia | Gif | null | Selected GIF media. | ✅ |
gifs | Gif[] | List of available GIFs. | |
loadingGifs | boolean | Indicates if GIFs are being loaded. | |
errorOnGifs | string | null | Error message if GIF loading fails. | ✅ |
gifQuery | string | The current search query for GIFs. | |
openGifCollapse | boolean | Indicates whether the GIF search section is open. | |
updateInputText | onChangeUpdateInputText | Function to update input text. | |
onTextInputKeydownHandler | onKeydownEvent | Function handling keydown events in the input. | |
onTextInputKeyUpHandler | onKeyUpEvent | Function handling keyup events in the input. | |
clearTaggingList | ZeroArgVoidReturns | Clears the tagging suggestions list. | |
addEmojiToText | TwoArgVoidReturns<EmojiData, MouseEventS> | Adds an emoji to the input text. | |
addImagesAndVideosMedia | OneArgVoidReturns <ChangeEvent<HTMLInputElement>> | Handles adding image and video files. | |
addDocumentsMedia | OneArgVoidReturns <ChangeEvent<HTMLInputElement>> | Handles adding document files. | |
postMessage | OneOptionalArgVoidReturns<Record<string, anyS>S> | Posts a message. | |
getTaggingMembers | OneOptionalArgVoidReturns<number> | Fetches tagging members. | |
removeOgTag | ZeroArgVoidReturns | Removes the Open Graph tag from the input. | |
setGifMedia | Dispatch<Gif | null> | Sets the selected GIF media. | |
setOpenGifCollapse | Dispatch<boolean> | Sets the state of the GIF search collapse. | |
gifSearchQuery | OneArgVoidReturns <string> | Sets the GIF search query. | |
fetchGifs | OneArgVoidReturns <string> | Fetches GIFs based on a search query. | |
handleGifSearch | ZeroArgVoidReturns | Triggers a GIF search. | |
removeMediaFromImageList | OneArgVoidReturns | Removes an image or video file from the media list. | |
removeMediaFromDocumentList | OneArgVoidReturns | Removes a document file from the media list. | |
sendDMRequest | OneArgVoidReturns <string> | Sends a direct message (DM) request. | |
rejectDMRequest | ZeroArgVoidReturns | Rejects a DM request. | |
approveDMRequest | ZeroArgVoidReturns | Approves a DM request. | |
alertMessage | string | null | Message to display in an alert. | ✅ |
shouldShowInputBox | ZeroArgBooleanReturns | Determines whether the input box should be visible. |
Reference
For reference checkout this file