Skip to content

Commit b90ea46

Browse files
committed
refactor: update ExpoMessaging to use WithComponents
- Channel screen: MessageLocation and InputButtons moved to WithComponents - Fix InputButtons type to use ComponentOverrides instead of Channel props
1 parent bad66b1 commit b90ea46

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

examples/ExpoMessaging/app/channel/[cid]/index.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
useChatContext,
77
ThreadContextValue,
88
MessageList,
9+
WithComponents,
910
} from 'stream-chat-expo';
1011
import { Stack, useLocalSearchParams, useRouter } from 'expo-router';
1112
import { AuthProgressLoader } from '../../../components/AuthProgressLoader';
@@ -70,22 +71,23 @@ export default function ChannelScreen() {
7071
<Stack.Screen
7172
options={{ title: 'Channel Screen', contentStyle: { backgroundColor: 'white' } }}
7273
/>
73-
<Channel
74-
audioRecordingEnabled={true}
75-
channel={channel}
76-
onPressMessage={onPressMessage}
77-
keyboardVerticalOffset={headerHeight}
78-
MessageLocation={MessageLocation}
79-
thread={thread}
80-
>
81-
<MessageList
82-
onThreadSelect={(thread: ThreadContextValue['thread']) => {
83-
setThread(thread);
84-
router.push(`/channel/${channel.cid}/thread/${thread?.cid ?? ''}`);
85-
}}
86-
/>
87-
<MessageComposer InputButtons={InputButtons} />
88-
</Channel>
74+
<WithComponents value={{ MessageLocation, InputButtons }}>
75+
<Channel
76+
audioRecordingEnabled={true}
77+
channel={channel}
78+
onPressMessage={onPressMessage}
79+
keyboardVerticalOffset={headerHeight}
80+
thread={thread}
81+
>
82+
<MessageList
83+
onThreadSelect={(thread: ThreadContextValue['thread']) => {
84+
setThread(thread);
85+
router.push(`/channel/${channel.cid}/thread/${thread?.cid ?? ''}`);
86+
}}
87+
/>
88+
<MessageComposer />
89+
</Channel>
90+
</WithComponents>
8991
</View>
9092
);
9193
}

examples/ExpoMessaging/components/InputButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React, { useState } from 'react';
22
import { Pressable, StyleSheet } from 'react-native';
3-
import { Channel, InputButtons as DefaultInputButtons } from 'stream-chat-expo';
3+
import type { ComponentOverrides } from 'stream-chat-expo';
4+
import { InputButtons as DefaultInputButtons } from 'stream-chat-expo';
45
import { ShareLocationIcon } from '../icons/ShareLocationIcon';
56
import { LiveLocationCreateModal } from './LocationSharing/CreateLocationModal';
67

7-
const InputButtons: NonNullable<React.ComponentProps<typeof Channel>['InputButtons']> = (props) => {
8+
const InputButtons: NonNullable<ComponentOverrides['InputButtons']> = (props) => {
89
const [modalVisible, setModalVisible] = useState(false);
910

1011
const onRequestClose = () => {

0 commit comments

Comments
 (0)