-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
52 lines (44 loc) · 1.31 KB
/
Copy pathApp.js
File metadata and controls
52 lines (44 loc) · 1.31 KB
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
52
import React, {Component} from "react";
import Chat from "./components/Chat";
import Menu from "./components/Menu";
export default class App extends Component {
constructor() {
super();
this.state = {
page: 'Menu',
CurrentRoomID: 0,
BTSId: 17663660,
EXOId: 17733701,
Username: ''
}
}
SetRoom = (roomName) => {
if (roomName === 'BTS')
this.setState(previousState => ({
CurrentRoomID: previousState.BTSId
}));
else if (roomName === "EXO")
this.setState(previousState => ({
CurrentRoomID: previousState.EXOId
}));
console.warn(this.state.CurrentRoomID);
}
ToChat = () => {
const chat = 'Chat';
this.setState({page: chat});
}
SetUsername = (username) => {
this.setState({Username: username});
}
// componentWillMount() {
// const menu='menu';
// this.ToRoom(menu);
// }
render() {
const page = this.state.page;
if (page === 'Chat')
return <Chat roomId={this.state.CurrentRoomID} username={this.state.Username}/>;
else
return <Menu onSetRoom={this.SetRoom} onSubmit={this.SetUsername} onPress={this.ToChat}/>
}
}