AttachmentPickerContext

AttachmentPickerContext is provided by Channel. If you are not familiar with the React Context API, see the React docs.

Best Practices

  • Use useAttachmentPickerContext for consistent access and typings.
  • Manage picker visibility through openPicker/closePicker to keep state aligned.
  • Prefer setting topInset and bottomInset on Channel for normal screen layout, and keep those values consistent with your layout.
  • Avoid using the picker context outside Channel to prevent undefined state.
  • Keep custom picker UI lightweight to preserve input performance.

Basic Usage

Consume AttachmentPickerContext in any child of Channel:

import { useContext } from "react";
import { AttachmentPickerContext } from "stream-chat-react-native";

const { openPicker, closePicker } = useContext(AttachmentPickerContext);

Alternatively, use the useAttachmentPickerContext hook.

import { useAttachmentPickerContext } from "stream-chat-react-native";

const { openPicker, closePicker } = useAttachmentPickerContext();

Values

ValueDescriptionType
attachmentPickerBottomSheetHeightHeight of the attachment picker bottom sheet.number
attachmentPickerStoreState store instance that manages the internal state of the attachment picker, including selected images and picker type.AttachmentPickerStore
attachmentSelectionBarHeightHeight of the attachment selection bar.number
bottomInsetHeight of items located below the MessageComposer when present. This inset determines the underlying shift to the MessageList when it is opened. For most apps, set this through Channel. Update it from the context only when the inset needs to change dynamically after mount. Defaults to 0.number
bottomSheetRefReference to the attachment picker bottom sheet.React.RefObject<BottomSheet>
closePickerFunction to close the attachment picker bottom sheet.() => void
disableAttachmentPickerWhen true, the attachment picker is disabled entirely.boolean
numberOfAttachmentImagesToLoadPerCallNumber of images to load per pagination call in the attachment picker.number
numberOfAttachmentPickerImageColumnsNumber of columns to display in the attachment picker image grid.number
openPickerFunction to open the attachment picker bottom sheet.() => void
topInsetDistance from the top of the screen the attachment picker should open to when expanded. This is often set to the header height. For most apps, set this through Channel. Update it from the context only when the inset needs to change dynamically after mount. Defaults to 0.number