You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/reactnative/customization/typescript.mdx
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,13 +24,13 @@ The [documentation on `stream-chat-js` TypeScript](https://github.com/GetStream/
24
24
The client a generic type that defines seven customizable fields that currently exist in [`stream-chat-js`](https://github.com/GetStream/stream-chat-js#typescript-v2xx).
where `StreamChatType` can be defined as a type with the seven generics that correspond to the seven customizable fields as follows:
30
+
where `StreamChatGenerics` can be defined as a type with the seven generics that correspond to the seven customizable fields as follows:
31
31
32
32
```tsx
33
-
typeStreamChatType= {
33
+
typeStreamChatGenerics= {
34
34
attachmentType:LocalAttachmentType;
35
35
channelType:LocalChannelType;
36
36
commandType:LocalCommandType;
@@ -93,7 +93,7 @@ Additional fields on the defaults, i.e. `image`, are custom fields used by `stre
93
93
When wanting to set a subset of generics, the preceding and interceding generics must also be set for the TypeScript compiler to understand intent correctly.
@@ -121,7 +121,7 @@ The [TypeScript Example App](https://github.com/GetStream/stream-chat-react-nati
121
121
Core to understanding this usage is [how generics can be applied to JSX elements](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#generic-type-arguments-in-jsx-elements).
122
122
123
123
In many cases the use of a single prop such as `client` or `channel` allows TypeScript to infer the generics on an element.
124
-
In this case `channelType` within `StreamChatType` is inferred from `channel` and passed to the props type for a custom Attachment component.
124
+
In this case `channelType` within `StreamChatGenerics` is inferred from `channel` and passed to the props type for a custom Attachment component.
125
125
126
126
<imgsrc={inference}alt='TypeScript Inference' />
127
127
@@ -130,7 +130,7 @@ In these cases the generics must be applied to the component directly.
130
130
`MessageList` for instance could have the previous generics used on `client` applied to it in a similar manner.
131
131
132
132
```tsx
133
-
<MessageList<StreamChatType>
133
+
<MessageList<StreamChatGenerics>
134
134
onThreadSelect={thread=> {
135
135
/** Set thread and navigate to thread screen */
136
136
}}
@@ -147,7 +147,7 @@ Hooks, including those to access contexts, also require generics to be applied t
147
147
`useChannelContext` for instance would have the previous generics applied to it to get a correctly typed return for `channel`.
@@ -161,5 +161,5 @@ The lack of partial inference is particularly relevant if Higher Order Component
161
161
The `withChannelContext` HOC accepts the generics similarly to the `useChannelContext` hook, but because partial inference is not supported the props for the wrapped component must also be explicitly provided.
0 commit comments