Skip to content

Custom component delayed rendering causes issue when building the static pages #4333

Answered by slorber
guillaume-ion asked this question in Q&A
Discussion options

You must be logged in to vote

Docusaurus produce the static pages without waiting for any fetch to complete. No componentDidMount or useEffect are run during this process.

If you want to provide data fetched from an API, you have 2 choices:

  • Render that data only on the client
  • Ensure Docusaurus has the data when it renders on the server

If you want to ensure that Docusaurus has the data, you could just fetch that data ahead of time in a build step, like fetch a json file in website/data/myData.json, and import it with @site/data/myData.json.

We'll allow later to have an async config file, that would be able to fetch remote data and pass it to your site using config.customFields

You can also create a plugin for that, …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@guillaume-ion
Comment options

@slorber
Comment options

@guillaume-ion
Comment options

@guillaume-ion
Comment options

Answer selected by guillaume-ion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants