-
{displayTitle ?? channel.data?.name ?? 'Unnamed Channel'}
- {latestMessagePreview ? (
-
{latestMessagePreview}
+
{displayTitle ?? channel.data?.custom?.name ?? 'Unnamed Channel'}
+ {previewedMessage ? (
+
+
+
) : null}
@@ -137,9 +140,12 @@ const App = () => {
const initChannel = async () => {
const channel = client.channel('messaging', 'react-tutorial', {
- image: 'https://getstream.io/random_png/?name=react-v14',
- name: 'Talk about React',
members: [userId],
+ // custom channel fields live under `custom` since v10
+ custom: {
+ image: 'https://getstream.io/random_png/?name=react-v14',
+ name: 'Talk about React',
+ },
});
await channel.watch();
diff --git a/examples/tutorial/src/5-custom-attachment-type/App.tsx b/examples/tutorial/src/5-custom-attachment-type/App.tsx
index f69598573..6e14b9a3e 100644
--- a/examples/tutorial/src/5-custom-attachment-type/App.tsx
+++ b/examples/tutorial/src/5-custom-attachment-type/App.tsx
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import type {
Attachment as AttachmentType,
+ ClientUser,
Channel as StreamChannel,
- User,
} from 'stream-chat';
import {
Attachment,
@@ -20,7 +20,7 @@ import {
import './layout.css';
import { apiKey, tokenProvider, userId, userName } from '../1-client-setup/credentials';
-const user: User = {
+const user: ClientUser = {
id: userId,
name: userName,
image: `https://getstream.io/random_png/?name=${userName}`,
@@ -28,10 +28,14 @@ const user: User = {
const attachments: AttachmentType[] = [
{
- image: 'https://images-na.ssl-images-amazon.com/images/I/71k0cry-ceL._SL1500_.jpg',
- name: 'iPhone',
type: 'product',
- url: 'https://goo.gl/ppFmcR',
+ // fields that are not part of the Attachment API go under `custom` — this example declares them
+ // through module augmentation in ./stream-chat.d.ts
+ custom: {
+ image: 'https://images-na.ssl-images-amazon.com/images/I/71k0cry-ceL._SL1500_.jpg',
+ name: 'iPhone',
+ url: 'https://goo.gl/ppFmcR',
+ },
},
];
@@ -55,14 +59,16 @@ const CustomAttachment = (props: AttachmentProps) => {