import { useContext } from "react";
import { ChatContext } from "stream-chat-react-native";
const { client, isOnline } = useContext(ChatContext);
ChatContext
ChatContext
is provided by Chat
component. If you are not familiar with React Context API, please read about it on React docs.
Basic Usage
ChatContext
can be consumed by any of the child component of Chat
component as following:
Alternatively, you can also use useChatContext
hook provided by library to consume ChatContext.
import { useChatContext } from "stream-chat-react-native";
const { client, isOnline } = useChatContext();
Value
client
Instance of StreamChat client.
Type |
---|
StreamChat |
connectionRecovering
The value is true, when connection to WebSocket server is disconnected and is currently being recovered.
Type |
---|
boolean |
isOnline
The value is true, when current user is connected to chat.
Type |
---|
boolean |
ImageComponent
Drop in replacement of all the underlying Image
components within SDK.
This is useful for the purpose of offline caching of images. Please check the Offline Support Guide for usage.
Type | Default |
---|---|
ComponentType | Image |
mutedUsers
Array of users muted by current user.
Type |
---|
array |
resizableCDNHosts
This option allows you to specify a list of CDNs that offer image resizing.
Type | Default |
---|---|
string[] | ['.stream-io-cdn.com'] |