Skip to content

[lexical-react] Bug Fix: Add getServerSnapshot for RSC compatibility#7935

Merged
etrepum merged 1 commit intofacebook:mainfrom
nestarz:fix-7934-missing-getserversnapshot
Oct 20, 2025
Merged

[lexical-react] Bug Fix: Add getServerSnapshot for RSC compatibility#7935
etrepum merged 1 commit intofacebook:mainfrom
nestarz:fix-7934-missing-getserversnapshot

Conversation

@nestarz
Copy link
Copy Markdown
Contributor

@nestarz nestarz commented Oct 20, 2025

Description

  • Current behavior: When using Lexical in a React Server Components (RSC) environment (e.g., Next.js App Router), a console warning appears: useSyncExternalStore missing getServerSnapshot, which is required for server-rendered content. This is caused by the useSyncExternalStore hook in useReactDecorators.tsx being called without the required third argument.

  • Changes in this PR: This PR passes the existing getSnapshot function as the third argument (getServerSnapshot) to the useSyncExternalStore hook. This satisfies the hook's API for server rendering, resolves the warning, and ensures correct hydration in RSC environments.

Closes #7934

Test plan

The test plan follows the reproduction steps outlined in the issue.

  1. Set up a project using React Server Components (e.g., Next.js with the App Router).
  2. Install and render a Lexical editor.
  3. Run the development server and observe the browser's developer console.

Before

The following warning is visible in the console, and there may be hydration mismatch errors.

useSyncExternalStore missing getServerSnapshot, which is required for server-rendered content

After

The useSyncExternalStore warning is no longer present in the console, and the editor component hydrates correctly without errors.

This adds the missing getServerSnapshot argument to the useSyncExternalStore call, resolving hydration warnings in RSC environments. Fixes facebook#7934
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Oct 20, 2025

Hi @nestarz!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 20, 2025 6:19pm
lexical-playground Ready Ready Preview Comment Oct 20, 2025 6:19pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Oct 20, 2025

The PR title and description should be changed to match the pull request template and you'll need to accept the CLA but other than that this looks like it will be good to merge for the next release.

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Oct 20, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 20, 2025
@nestarz nestarz changed the title fix(react): Add getServerSnapshot for RSC compatibility [lexical-react] Bug Fix: Add getServerSnapshot for RSC compatibility Oct 20, 2025
@etrepum etrepum added this pull request to the merge queue Oct 20, 2025
Merged via the queue into facebook:main with commit 6836604 Oct 20, 2025
40 checks passed
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: useSyncExternalStore missing getServerSnapshot in RSC with Lexical v0.37.0

2 participants