facebook / facebook/docusaurus

onRouteDidUpdate does not see new Head metadata

Đang mở
#8,278 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.