You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because the theme uses const {search, hash} = useLocation() to render UI elements, but unfortunately, this hook returns the current/immediate browser search/hash, which is different from what we use on the server (always empty due to our SSG nature).
There's probably a way to configure React Router to output hydration-safe values when using useLocation(), but I'm not 100% sure it's a good idea, it's more risky, and may lead to extra re-renders on things that do not care about search/hash.
Instead I made useHistorySelector hydration-safe, ensuring that on hydration it always have empty/search like it does on the server.
Test Plan
Deploy preview + local
This should fix warnings we get in Argos, and repair it because it was broken due to such new warning introduced due to an iframe embed in v3.8 blog post.
slorber
added
Argos
Add this label to run UI visual regression tests. See argos.yml GH action.
pr: bug fix
This PR fixes a bug in a past release.
and removed
CLA Signed
Signed Facebook CLA
labels
Jun 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArgosAdd this label to run UI visual regression tests. See argos.yml GH action.pr: bug fixThis PR fixes a bug in a past release.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When building in dev mode
docusaurus build --devwe get a lot of React hydration errors as long as we use search/hash URL parameters:On http://localhost:3000/?param or http://localhost:3000/#hash we get:
This is because the theme uses
const {search, hash} = useLocation()to render UI elements, but unfortunately, this hook returns the current/immediate browser search/hash, which is different from what we use on the server (always empty due to our SSG nature).There's probably a way to configure React Router to output hydration-safe values when using
useLocation(), but I'm not 100% sure it's a good idea, it's more risky, and may lead to extra re-renders on things that do not care about search/hash.Instead I made
useHistorySelectorhydration-safe, ensuring that on hydration it always have empty/search like it does on the server.Test Plan
Deploy preview + local
This should fix warnings we get in Argos, and repair it because it was broken due to such new warning introduced due to an iframe embed in v3.8 blog post.
Test links
https://deploy-preview-11263--docusaurus-2.netlify.app/