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
-[Fully featured messaging application](./examples/SampleApp)
51
51
52
52
Besides, our team maintains a dedicated repository for fully-fledged sample applications and demos at [GetStream/react-native-samples](https://github.com/GetStream/react-native-samples). Please consider checking following sample applications:
Copy file name to clipboardExpand all lines: docusaurus/docs/reactnative/basics/troubleshooting.mdx
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,17 @@ dependencies {
246
246
}
247
247
```
248
248
249
+
## Blank screen when channel gets delete
250
+
251
+
When a channel is deleted, and if some user is active on that channel, a blank screen appears by default (as per the default logic) as we return `null` in this case. It might be confusing for end user to see a blank screen and appropriate UX would be to navigate back to channel list screen. You can implement such UX by listening to `channel.deleted` event on channel screen, and navigate to channel list screen with appropriate notification on app.
252
+
253
+
````tsx
254
+
client.on('channel.deleted', (event) => {
255
+
if (event.cid===channel.cid) {
256
+
// add your action here
257
+
}
258
+
}),
259
+
249
260
## Touchables not working
250
261
251
262
If you are having trouble with pressing, swiping, or otherwise interacting with components it is likely the result of [React Native Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/docs/) not being properly setup.
@@ -255,7 +266,7 @@ This includes ensuring you import `react-native-gesture-handler` at the top of y
255
266
256
267
```tsx
257
268
import 'react-native-gesture-handler';
258
-
```
269
+
````
259
270
260
271
And for Android you additionally need to update `MainActivity.java` to override the method for creating the `ReactRootView`.
Please refer to our typescript guide for details of [Generics](../customization/typescript.mdx#generics).
241
+
215
242
## Whats new in v4?
216
243
217
244
### Optimized Image Attachments
@@ -286,6 +313,52 @@ user won't be able to see a cropped image on UI. In this version, we render imag
286
313
</TabItem>
287
314
</Tabs>
288
315
316
+
### Refactor Generics to a Single Generic
317
+
318
+
The Typescript generics have been simplified to a single generic instead of 7 different generics (as in previous versions of SDK) which should be passed to the component or StreamChat client.
Copy file name to clipboardExpand all lines: docusaurus/docs/reactnative/customization/typescript.mdx
+58-48Lines changed: 58 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,20 +21,48 @@ In many cases TypeScript can use [inference](https://www.typescriptlang.org/docs
21
21
22
22
It is important that the proper generics be applied to the `stream-chat-js` client when it is instantiated.
23
23
The [documentation on `stream-chat-js` TypeScript](https://github.com/GetStream/stream-chat-js#typescript-v2xx) has examples of how this can be done in detail.
24
-
The client takes seven optional generics that correspond to the seven customizable fields that currently exist in `stream-chat-js`.
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).
All seven generics contain defaults in the `stream-chat-react-native` repo that you can extend for custom data.
76
+
All seven generics contain defaults in the `stream-chat-react-native` repo that you can extend for custom data such as custom types for Channels, Messages, etc.
Additional fields on the defaults i.e. `file_size`, `mime_type`, and `image` are custom fields used by `stream-chat-react-native` already within the SDK.
68
-
When wanting to set a subset of generics the preceding and interceding generics must also be set in order for the TypeScript compiler to correctly understand intent.
92
+
Additional fields on the defaults, i.e. `image`, are custom fields used by `stream-chat-react-native` already within the SDK.
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.
69
94
70
-
To set `ChannelType` and `MessageType` for `AttachmentType`, `CommandType`, and `EventType` must also be set.
@@ -92,7 +121,7 @@ The [TypeScript Example App](https://github.com/GetStream/stream-chat-react-nati
92
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).
93
122
94
123
In many cases the use of a single prop such as `client` or `channel` allows TypeScript to infer the generics on an element.
95
-
In this case `LocalAttachmentType` 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.
96
125
97
126
<imgsrc={inference}alt='TypeScript Inference' />
98
127
@@ -101,13 +130,7 @@ In these cases the generics must be applied to the component directly.
101
130
`MessageList` for instance could have the previous generics used on `client` applied to it in a similar manner.
102
131
103
132
```tsx
104
-
<MessageList<
105
-
DefaultAttachmentType,
106
-
{ image?:string; nickName?:string },
107
-
DefaultCommandType,
108
-
DefaultEventType,
109
-
{ isAdminMessage?:boolean }
110
-
>
133
+
<MessageList<StreamChatGenerics>
111
134
onThreadSelect={thread=> {
112
135
/** Set thread and navigate to thread screen */
113
136
}}
@@ -124,13 +147,7 @@ Hooks, including those to access contexts, also require generics to be applied t
124
147
`useChannelContext` for instance would have the previous generics applied to it to get a correctly typed return for `channel`.
@@ -144,12 +161,5 @@ The lack of partial inference is particularly relevant if Higher Order Component
144
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