Skip to content

Commit

Permalink
docs: add example on how to declare StreamChat options variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Aug 5, 2024
1 parent fff18e4 commit 729842b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docusaurus/docs/React/basics/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,35 @@ To communicate with the Stream Chat API the SDK requires a client with an establ

:::important
The hook `useCreateChatClient` accepts parameter `options`. This is an object forwarded to the `StreamChat` constructor. Please make sure the `options` object is created outside the scope of the component invoking `useCreateChatClient` to prevent unnecessary re-renders and thus reconnects.

```
import {
Chat,
StreamChatOptions,
useCreateChatClient,
} from 'stream-chat-react';
const streamChatOptions: StreamChatOptions = {
timeout: 6000
}
const App = () => {
const client = useCreateChatClient({
apiKey,
options: streamChatOptions,
tokenOrProvider: token,
userData: { id: userId },
});
if (!client) return <div>Loading...</div>;
return (
<Chat client={client}>
</Chat>
);
}
```

:::

## Creating a Channel
Expand Down

0 comments on commit 729842b

Please sign in to comment.