-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
32 lines (26 loc) · 774 Bytes
/
App.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
import React from 'react';
import MainScreen from './Components/MainScreen';
import LoginScreen from './Components/LoginScreen';
import User from './Services/User';
import CurrentUser from './Services/CurrentUser';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
currentUser: null,
users: User.findAll(),
};
this.setCurrentUser = this.setCurrentUser.bind(this);
}
setCurrentUser(currentUser) {
CurrentUser.set(currentUser);
this.setState({ currentUser });
}
render() {
if (!this.state.currentUser) {
return <LoginScreen users={this.state.users} action={this.setCurrentUser} />;
}
return <MainScreen currentUser={this.state.currentUser} />;
}
}
export default App;