Skip to content

Commit c9cf6c9

Browse files
committed
Firebase - Section 9
1 parent 6336102 commit c9cf6c9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

todos/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<head>
22
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
3+
<style>
4+
.content {
5+
opacity: 0;
6+
transition: opacity 1s ease-in;
7+
}
8+
.loaded {
9+
opacity: 1;
10+
}
11+
</style>
312
</head>
413
<body>
514
<div class="container">

todos/src/app.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ var App = React.createClass({
99
mixins: [ ReactFire ],
1010
getInitialState: function() {
1111
return {
12-
items: {}
12+
items: {},
13+
loaded: false
1314
}
1415
},
1516
componentWillMount: function() {
16-
this.bindAsObject(new Firebase(rootUrl + 'items/'), 'items');
17+
fb = new Firebase(rootUrl + 'items/');
18+
this.bindAsObject(fb, 'items');
19+
fb.on('value', this.handleDataLoaded);
1720
},
1821
render: function() {
1922
return <div className="row panel panel-default">
@@ -22,9 +25,14 @@ var App = React.createClass({
2225
To-Do List
2326
</h2>
2427
<Header itemsStore={this.firebaseRefs.items} />
25-
<List items={this.state.items} />
28+
<div className={"content " + (this.state.loaded ? 'loaded' : '')}>
29+
<List items={this.state.items} />
30+
</div>
2631
</div>
2732
</div>
33+
},
34+
handleDataLoaded: function(){
35+
this.setState({loaded: true});
2836
}
2937
});
3038

0 commit comments

Comments
 (0)