import { useNotificationTarget } from "stream-chat-react-native";
const panel = useNotificationTarget();
// → 'channel' | 'thread' | 'channel-list' | 'thread-list' | undefineduseNotificationTarget
useNotificationTarget returns the panel that the calling component lives in. It inspects React context (ChannelContext, ThreadContext, ThreadsContext, ChannelsContext) and returns the matching panel string. Use it in custom notification UI when you need the panel name; the default snackbar routing uses NotificationTargetProvider for exact host targeting.
Usage
Returns
NotificationTargetPanel | undefined. The panel is resolved as follows, in order:
| Condition | Panel |
|---|---|
Mounted inside a Channel with threadList set on ChannelContext | 'thread' |
Mounted inside a Thread with a threadInstance on ThreadContext | 'thread' |
Mounted inside a Channel with a channel on ChannelContext | 'channel' |
Mounted inside a ThreadList with ThreadsContext present | 'thread-list' |
Mounted inside a ChannelList with ChannelsContext present | 'channel-list' |
| None of the above | undefined |
The first matching condition wins.
If you need to disambiguate between multiple instances of the same panel (e.g. two thread views on the same screen), wrap the subtree in NotificationTargetProvider with a stable hostId.