Skip to content

Commit ad22ccd

Browse files
committed
fix: usage of global config
1 parent cf9ccf7 commit ad22ccd

File tree

1 file changed

+13
-23
lines changed
  • examples/TypeScriptMessaging

1 file changed

+13
-23
lines changed

examples/TypeScriptMessaging/App.tsx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
Streami18n,
2525
Thread,
2626
ThreadContextValue,
27-
useChatContext,
2827
useCreateChatClient,
2928
useOverlayContext,
3029
} from 'stream-chat-react-native';
@@ -147,17 +146,6 @@ const ThreadScreen: React.FC<ThreadScreenProps> = ({ navigation }) => {
147146
const { channel, setThread, thread } = useContext(AppContext);
148147
const headerHeight = useHeaderHeight();
149148
const { overlay } = useOverlayContext();
150-
const { client } = useChatContext();
151-
152-
useEffect(() => {
153-
client.setMessageComposerSetupFunction(({ composer }) => {
154-
composer.updateConfig({
155-
drafts: {
156-
enabled: true,
157-
},
158-
});
159-
});
160-
}, [client]);
161149

162150
useEffect(() => {
163151
navigation.setOptions({
@@ -209,17 +197,6 @@ const AppContext = React.createContext({} as AppContextType);
209197

210198
const NavigatorModule = () => {
211199
const { channel } = useContext(AppContext);
212-
const { client } = useChatContext();
213-
214-
useEffect(() => {
215-
client.setMessageComposerSetupFunction(({ composer }) => {
216-
composer.updateConfig({
217-
drafts: {
218-
enabled: true,
219-
},
220-
});
221-
});
222-
}, [client]);
223200

224201
return (
225202
<Stack.Navigator
@@ -263,6 +240,19 @@ const App = () => {
263240
tokenOrProvider: userToken,
264241
});
265242

243+
useEffect(() => {
244+
if (!chatClient) {
245+
return;
246+
}
247+
chatClient.setMessageComposerSetupFunction(({ composer }) => {
248+
composer.updateConfig({
249+
drafts: {
250+
enabled: true,
251+
},
252+
});
253+
});
254+
}, [chatClient]);
255+
266256
if (!chatClient) {
267257
return <AuthProgressLoader />;
268258
}

0 commit comments

Comments
 (0)