Add error message if loading fails
This commit is contained in:
@@ -27,7 +27,10 @@ export default class App extends React.Component {
|
||||
componentDidMount() {
|
||||
this.setState({isLoaded: false})
|
||||
this.mockService.getStats()
|
||||
.then(data => this.setState({mock: data}));
|
||||
.then(data => this.setState({
|
||||
data: data,
|
||||
mock: data
|
||||
}));
|
||||
this.apiService.getStats()
|
||||
.then(data => this.setState({
|
||||
isLoaded: true,
|
||||
@@ -86,13 +89,14 @@ export default class App extends React.Component {
|
||||
return (
|
||||
<div className="App">
|
||||
<p className="title">Humenius' TeamSpeak 3-Ranking</p>
|
||||
{ this.state.error != null ? <p className="error-message">Data could not be loaded. Please try again later!</p> : null}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Placement</th>
|
||||
<th>Name</th>
|
||||
<th>Online time</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Placement</th>
|
||||
<th>Name</th>
|
||||
<th>Online time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className={this.state.error != null ? "blurred" : undefined}>
|
||||
{this.renderTableData()}
|
||||
|
||||
Reference in New Issue
Block a user