Skip to main content

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.

PropertyTypeDescriptionOptional
inputBoxRefMutableRefObject<HTMLDivElement | null>Reference to the input box element.
inputWrapperRefMutableRefObject<HTMLDivElement | null>Reference to the input wrapper element.
inputTextstringThe current text in the input field.
matchedTagMembersListMember[]List of members matching the tagging input.
fetchMoreTagsbooleanIndicates whether more tag suggestions need to be fetched.
imagesAndVideosMediaListFile[] | nullList of image and video files selected.
documentsMediaListFile[] | nullList of document files selected.
ogTagOgTag | nullOpen Graph (OG) tag metadata, if present.
gifMediaGif | nullSelected GIF media.
gifsGif[]List of available GIFs.
loadingGifsbooleanIndicates if GIFs are being loaded.
errorOnGifsstring | nullError message if GIF loading fails.
gifQuerystringThe current search query for GIFs.
openGifCollapsebooleanIndicates whether the GIF search section is open.
updateInputTextonChangeUpdateInputTextFunction to update input text.
onTextInputKeydownHandleronKeydownEventFunction handling keydown events in the input.
onTextInputKeyUpHandleronKeyUpEventFunction handling keyup events in the input.
clearTaggingListZeroArgVoidReturnsClears the tagging suggestions list.
addEmojiToTextTwoArgVoidReturns<EmojiData, MouseEventS>Adds an emoji to the input text.
addImagesAndVideosMediaOneArgVoidReturns<ChangeEvent<HTMLInputElement>>Handles adding image and video files.
addDocumentsMediaOneArgVoidReturns<ChangeEvent<HTMLInputElement>>Handles adding document files.
postMessageOneOptionalArgVoidReturns<Record<string, anyS>S>Posts a message.
getTaggingMembersOneOptionalArgVoidReturns<number>Fetches tagging members.
removeOgTagZeroArgVoidReturnsRemoves the Open Graph tag from the input.
setGifMediaDispatch<Gif | null>Sets the selected GIF media.
setOpenGifCollapseDispatch<boolean>Sets the state of the GIF search collapse.
gifSearchQueryOneArgVoidReturns<string>Sets the GIF search query.
fetchGifsOneArgVoidReturns<string>Fetches GIFs based on a search query.
handleGifSearchZeroArgVoidReturnsTriggers a GIF search.
removeMediaFromImageListOneArgVoidReturnsRemoves an image or video file from the media list.
removeMediaFromDocumentListOneArgVoidReturnsRemoves a document file from the media list.
sendDMRequestOneArgVoidReturns<string>Sends a direct message (DM) request.
rejectDMRequestZeroArgVoidReturnsRejects a DM request.
approveDMRequestZeroArgVoidReturnsApproves a DM request.
alertMessagestring | nullMessage to display in an alert.
shouldShowInputBoxZeroArgBooleanReturnsDetermines whether the input box should be visible.

Reference

For reference checkout this file