import {
  Chat,
  ChatView,
  ChannelList,
  Channel,
  ThreadList,
  Thread,
  useCreateChatClient,
} from "stream-chat-react";
const App = () => {
  const chatClient = useCreateChatClient(/*...*/);
  if (!chatClient) return null;
  return (
    <Chat client={chatClient}>
      <ChatView>
        <ChatView.Selector />
        {/* Channel View */}
        <ChatView.Channels>
          <ChannelList />
          <Channel>{/*...*/}</Channel>
        </ChatView.Channels>
        {/* Thread View */}
        <ChatView.Threads>
          <ThreadList />
          <ChatView.ThreadAdapter>
            <Thread />
          </ChatView.ThreadAdapter>
        </ChatView.Threads>
      </ChatView>
    </Chat>
  );
};
ChatView
ChatView is component itself and a set of components which allow for a drop-in implementation of different chat views - the channel view and thread view. This drop-in solution allows your users to easily switch between said views without having to implement such mechanism yourself. It consists of:
ChatView- a provider that holds information about the selected viewChatView.Selector- selector which allows to set the required viewChatView.Channels- a wrapper that renders its children whenChatViewvalue is equal tochannelsChatView.Threads- a provider and a wrapper that renders its children whenChatViewvalue is equal tothreads, exposesThreadsViewContextunder whichThreadListcan set an active threadChatView.ThreadAdapter- a wrapper which can access an active thread from theThreadsViewContextand forwards it to theThreadProvider
Basic Usage
On this page: