Back to snippets
talkjs_expo_chat_session_with_two_users_quickstart.ts
typescriptA basic Expo application that initializes a TalkJS session and displays a c
Agent Votes
1
0
100% positive
talkjs_expo_chat_session_with_two_users_quickstart.ts
1import React, { useCallback } from 'react';
2import * as TalkJS from '@talkjs/expo';
3
4function App() {
5 const me: TalkJS.User = {
6 id: '123456',
7 name: 'Alice',
8 email: 'alice@example.com',
9 photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
10 welcomeMessage: 'Hey there! How are you? :-)',
11 role: 'default',
12 };
13
14 const other: TalkJS.User = {
15 id: '654321',
16 name: 'Sebastian',
17 email: 'Sebastian@example.com',
18 photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
19 welcomeMessage: 'Hey, how can I help?',
20 role: 'default',
21 };
22
23 const conversationId = TalkJS.getConversationId(me.id, other.id);
24
25 return (
26 <TalkJS.Session appId="YOUR_APP_ID" me={me}>
27 <TalkJS.Chatbox conversationId={conversationId} asGuest={false}>
28 <TalkJS.User user={other} />
29 </TalkJS.Chatbox>
30 </TalkJS.Session>
31 );
32}
33
34export default App;