import { Thread, ThreadProvider } from "stream-chat-react";
<ThreadProvider thread={/*...*/}>
<Thread />
</ThreadProvider>;ThreadContext
ThreadContext provides thread data via React context. It’s populated by ThreadProvider.
Best Practices
- Prefer
ThreadProviderwhen you have aThreadinstance already available. - Keep
ThreadProviderscoped to the thread view to avoid unnecessary context updates. - Rely on
Thread’s built-in fallback toChannelstate only when needed. - Avoid mixing multiple thread sources in the same subtree.
- Keep thread data updates centralized to prevent inconsistent UI.
ThreadProvider
ThreadProvider wraps Channel and provides a Thread instance. The Channel wrapper is a temporary compatibility layer while the SDK transitions to using a Thread instance directly.
Thread prioritizes the provided Thread instance when rendered under ThreadProvider; otherwise it falls back to thread data from Channel state.