Skip to content

04: Adding suspense list

Latest
Compare
Choose a tag to compare
@mikehazell mikehazell released this 02 Dec 13:07
· 4 commits to master since this release

In this final step, we want to show Comments below the Post detail and above the related posts.

  • We start by adding the api method to api.js
  • Then we add the new data dependency to our route config.
  • We create the Comments component and read() in the data

The comments api is slower than the related posts api but because comments is shown above the related posts and because the comments are more important than related posts we want to control the order in which they are revealed.

To do this, we wrap them in a SuspenseList component. When given the prop revealOrder="forwards" it will alway wait for comments to be ready before showing related posts.