Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Adding loading message to async page
Browse files Browse the repository at this point in the history
Shows when content is loading on the client
  • Loading branch information
iaincollins committed Feb 13, 2017
1 parent 9efc03f commit 9457042
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/async.js
Expand Up @@ -42,6 +42,11 @@ export default class extends Page {
}

render() {
let loadingMessage
if (this.state.posts.length === 0) {
loadingMessage = <p><i>Loading content from jsonplaceholder.typicode.com…</i></p>
}

return (
<Layout session={this.props.session}>
<h2>Asynchronous data fetching</h2>
Expand All @@ -64,6 +69,7 @@ export default class extends Page {
when navigating to this page from another link on the site.
</p>
<hr/>
{loadingMessage}
{
this.state.posts.map((post, i) => (
<div key={i}>
Expand Down

0 comments on commit 9457042

Please sign in to comment.