import { useContext } from "react";
import { OverlayContext } from "stream-chat-react-native";
const { setOverlay } = useContext(OverlayContext);OverlayContext
OverlayContext is provided by OverlayProvider. If you are not familiar with the React Context API, see the React docs.
Best Practices
- Access
OverlayContextviauseOverlayContextfor cleaner code. - Keep overlay state centralized; avoid multiple overlay controllers in the tree.
- Use
overlayenum values consistently to prevent unexpected UI states. - Provide theme overrides at
OverlayProviderwhen you need overlay UI to match app theme. - Prefer context updates over direct component manipulation for overlay changes.
Basic Usage
Consume OverlayContext in any child of OverlayProvider:
Alternatively, use the useOverlayContext hook.
import { useOverlayContext } from "stream-chat-react-native";
const { setOverlay } = useOverlayContext();Values
| Value | Description | Type |
|---|---|---|
overlay | Current active overlay. Rendered for: 'alert' (delete message confirmation alert box), 'gallery' (when image viewer/gallery is opened), 'none' (default value). | enum('alert', 'gallery', 'none') |
overlayOpacity | A Reanimated SharedValue that tracks the current opacity of the overlay. Automatically animated to 1 when an overlay is active and 0 when dismissed. | SharedValue<number> |
setOverlay | Setter for overlay. You can use this setter to show the overlay. | (overlay) => void |
style | A theme object to customize the styles of SDK components. Detailed information on theming can be found in the customization documentation. Themes are inherited from parent providers. A theme provided to the OverlayProvider will be the base theme style is merged into. Themes are not hoisted though, therefore a theme provided to Chat will not change overlay components such as the attachment picker. | object |