-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroom.js
51 lines (49 loc) · 1.15 KB
/
room.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*import React, { Component } from 'react'
import { ActivityIndicator, StyleSheet, View } from 'react-native';
import {GiftedChat} from 'react-native-gifted-chat'
import Backend from './data/Backend';
export default class room extends Component {
constructor(){
super();
this.state={
load:false,
}
}
state={
messages:[],
}
componentDidMount(){
this.setState({load:true});
Backend.loadMessages(message=>{
this.setState( previousState=> {
return {
messages:GiftedChat.append(previousState.messages,message),
load:false,
}
})
})
}
componentWillUnmount(){
Backend.closeChat()
}
componentDidUpdate(){
}
render() {
return (
<View style={{flex:1}} >
<ActivityIndicator animating={this.state.load} color="black" size='large' />
<GiftedChat
messages={this.state.messages}
onSend={message => {
Backend.sendMessage(message);
}}
user={{
_id: Backend.getUid(),
name: Backend.getUsername(),
}}
/>
</View>
)
}
}
const styles = StyleSheet.create({})*/