Johannes Zellner 11 lat temu
rodzic
commit
6ec02d28e2
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7 3
      src/js/Application.js

+ 7 - 3
src/js/Application.js

@@ -12,17 +12,21 @@ var Application = React.createClass({
     this.refs.modalAdd.openModal();
   },
   getInitialState: function () {
-    return { data: [] };
+    return { data: [], busy: false };
   },
   componentDidMount: function () {
     var that = this;
 
+    that.setState({ data: [], busy: true });
+
     Core.thingsGet('', function (error, result) {
       if (error) return console.error(error);
-      that.setState({ data: result });
+      that.setState({ data: result, busy: false });
     });
   },
   render: function () {
+    var things = this.state.busy ? <center><i className="spinner"></i></center> : <ThingList data={this.state.data}/>;
+
     return (
       <div>
         <NewThing ref="modalAdd"/>
@@ -44,7 +48,7 @@ var Application = React.createClass({
           <div className="row">
             <div className="col-md-2"></div>
             <div className="col-md-8">
-              <ThingList data={this.state.data}/>
+              {things}
             </div>
             <div className="col-md-2"></div>
           </div>