facebook / facebook/docusaurus

onRouteDidUpdate does not see new Head metadata

Open
#8,278 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
66.2k
Forks
10k
Avg merge
1d 3h
Merged PRs (30d)
52

Description

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

When navigating between routes, the `onRouteDidUpdate` client module lifecycle does not see the newly updated Head / Helmet metadata

This leads to annoying usage of setTimeout in userland plugins.

As commented in https://github.com/facebook/docusaurus/issues/3399#issuecomment-1300174763, I believe this is due to `react-helmet-async` using `` by default (to confirm).

We should study the impact of turning `defer={false}`: performance or anything else

### Reproducible demo

_No response_

### Steps to reproduce

Take a deploy preview, navigate to another page, and look at console logs.
https://deploy-preview-8275--docusaurus-2.netlify.app/

![CleanShot 2022-11-02 at 12 41 44@2x](https://user-images.githubusercontent.com/749374/199481590-91461e33-78a8-4999-8b67-809429a66929.png)

### Expected behavior

title/description (and other metadata) should rather be correct

### Actual behavior

title/description is incorrect

### Your environment

_No response_

### Self-service

- [X] I'd be willing to fix this bug myself.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.