Skip to content

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

Value Description Type
attachmentPickerBottomSheetHeight Height of the attachment picker bottom sheet. number
attachmentPickerStore State store instance that manages the internal state of the attachment picker, including selected images and picker type. AttachmentPickerStore
attachmentSelectionBarHeight Height of the attachment selection bar. number
bottomInset Height 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
bottomSheetRef Reference to the attachment picker bottom sheet. React.RefObject<BottomSheet | null>
closePicker Function to close the attachment picker bottom sheet. () => void
disableAttachmentPicker When true, the attachment picker is disabled entirely. boolean
numberOfAttachmentImagesToLoadPerCall Number of images to load per pagination call in the attachment picker. number
numberOfAttachmentPickerImageColumns Number of columns to display in the attachment picker image grid. number
openPicker Function to open the attachment picker bottom sheet. () => void
topInset Distance 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