-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
51 lines (44 loc) · 1.18 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
Top-level component which has a state that can be changed to determine the page to show
**/
var React = require('react');
var Navigation = require('./components/Navigation.js');
var Feed = require('./components/Feed.js');
var StartBet = require('./components/StartBet.js');
var Profile = require('./components/Profile.js');
var App = React.createClass({
/**
page: feed | bet | profile
*/
getInitialState() {
return { page: 'feed' };
},
// callback function for nav bar to change page
changePage(pageName) {
return () => this.setState({page: pageName});
},
render: function() {
var activeComponent = null;
switch(this.state.page) {
case 'feed':
activeComponent = <Feed />;
break;
case 'bet':
activeComponent = <StartBet navCallback={this.changePage} />;
break;
case 'profile':
activeComponent = <Profile />;
break;
default:
activeComponent = <Feed />;
}
return (
<div>
<h1 id="header">TallyUp</h1>
<Navigation navCallback={this.changePage} currPage={this.state.page} />
{activeComponent}
</div>
);
}
});
module.exports = App;