Skip to content

fix: wrong hydration, hydrate twice#2063

Merged
SoonIter merged 1 commit intomainfrom
syt/rspress/fix-root-comp
Apr 14, 2025
Merged

fix: wrong hydration, hydrate twice#2063
SoonIter merged 1 commit intomainfrom
syt/rspress/fix-root-comp

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Apr 14, 2025

Summary

in #2033, introduced a useEffect hook to get initialData (after rendering)

 useEffect(() => {
    initPageData(window.location.pathname).then(pageData => {
      setData(pageData);
    });
  }, []);

before this pr

  1. beforeHydration, initialData: null, render the html

  2. afterHydration, hydrate the html

  3. useEffect, get initialData and render the html again

so we get two html in the same page

after this pr

  1. beforeHydration, initialData: {...}, render the html

  2. afterHydration, hydrate the html successfully

Related Issue

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit a926b92
🔍 Latest deploy log https://app.netlify.com/sites/rspress-v2/deploys/67fcacfeaa428100085ce38e
😎 Deploy Preview https://deploy-preview-2063--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2025

Deploy Preview for aquamarine-blini-95325f ready!

Name Link
🔨 Latest commit a926b92
🔍 Latest deploy log https://app.netlify.com/sites/aquamarine-blini-95325f/deploys/67fcacfe8c912800089e79be
😎 Deploy Preview https://deploy-preview-2063--aquamarine-blini-95325f.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🟢 up 5 from production)
Accessibility: 97 (no change from production)
Best Practices: 83 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@SoonIter SoonIter changed the title fix: wrong hydration, hydrate twice or fallback to csr fix: wrong hydration, hydrate twice Apr 14, 2025
@SoonIter SoonIter requested a review from Timeless0911 April 14, 2025 07:00
@SoonIter SoonIter merged commit 3702544 into main Apr 14, 2025
16 checks passed
@SoonIter SoonIter deleted the syt/rspress/fix-root-comp branch April 14, 2025 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants