Skip to content

Commit f5b47da

Browse files
committed
2 parents 1ee2599 + 63afc2f commit f5b47da

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

Example.js

+29-31
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1-
import React, { useEffect, useState, Component } from 'react';
1+
import React, { Component } from 'react';
22
import { Provider } from 'react-redux';
33

44
import { store } from './src/store';
55
import App from './src/components/App';
66
import ConversationWindow from './src/components/ConversationWindow';
77
import ConversationList from './src/components/ConversationList';
88
import { Channelize } from './channelize-websdk/dist/index';
9-
// import React, { useEffect } from 'react';
109

1110
if (process.env.NODE_ENV === 'development') {
1211
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
1312
console.disableYellowBox = true;
1413
}
1514

16-
const PUBLIC_KEY = "qHvonVEyIxDLa6zh"; //Channelize.io public key
17-
const LOGGEDIN_USER_ID = "20697" ;//User id of loggedin user
18-
const CH_ACCESS_TOKEN = "IM8At4OKh7lqDWZWWxJd6YtK5VWheqiYg5rttJgA9gG3PKVbDG2IbI9BQn2ihZu0"; //Channelize access token of loggedin userid
19-
const ANOTHER_USER_ID = "18859"; //The user id of another user to start chat
15+
const PUBLIC_KEY; //Channelize.io public key
16+
const LOGGEDIN_USER_ID;//User id of loggedin user
17+
const CH_ACCESS_TOKEN; //Channelize access token of loggedin userid
18+
const ANOTHER_USER_ID; //The user id of another user to start chat
2019

21-
export default (props) => {
22-
const [conversation, setConversation] = useState('');
20+
export default class Example extends Component {
21+
constructor(props) {
22+
super(props);
2323

24-
const client = new Channelize.client({publicKey: PUBLIC_KEY});
25-
26-
// let conversation;
27-
useEffect(() => {
28-
console.log('1111');
29-
getConversation();
30-
}, []);
24+
this.state = {
25+
conversation: null
26+
}
27+
}
3128

32-
const getConversation = async () => {
33-
console.log('2222');
34-
const res = await client.connect(LOGGEDIN_USER_ID, CH_ACCESS_TOKEN);
35-
console.log('res', res)
36-
const conversation = await client.Conversation.getConversation('1021')
37-
setConversation(conversation);
38-
};
29+
componentDidMount() {
30+
console.log('app is launched');
31+
}
3932

40-
if (!conversation) {
41-
return null;
33+
componentWillUnmount() {
34+
console.log('app is killed');
4235
}
4336

44-
return (
45-
<Provider store={store}>
46-
<App client={client} userId={LOGGEDIN_USER_ID} accessToken={CH_ACCESS_TOKEN}>
47-
<ConversationWindow conversation={conversation}/>
48-
</App>
49-
</Provider>
50-
)
37+
render() {
38+
var client = new Channelize.client({publicKey: PUBLIC_KEY});
39+
40+
return (
41+
<Provider store={store}>
42+
<App client={client} userId={LOGGEDIN_USER_ID} accessToken={CH_ACCESS_TOKEN}>
43+
<ConversationList />
44+
<ConversationWindow />
45+
</App>
46+
</Provider>
47+
);
48+
}
5149
}

0 commit comments

Comments
 (0)