Skip to content

[lexical-react] Bug Fix: Use the SSR-safe useLayoutEffect in Placeholder - #8906

Merged
etrepum merged 1 commit into
meta:mainfrom
arcs-:fix/content-editable-placeholder-ssr-layout-effect
Aug 2, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
arcs-:fix/content-editable-placeholder-ssr-layout-effect

Conversation

@arcs-

@arcs- arcs- commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Placeholder imported useLayoutEffect straight from react
  • every server render logs useLayoutEffect does nothing on the server

This PR uses the shared/useLayoutEffect instead, which removes the warning and seems to be the way this has been used in the past.

I also removed react-hooks/set-state-in-effect since it doesn't trigger anymore

Test plan

renderToString of a ContentEditable with a placeholder, dev build:

Before

1 warning

After

0 warnings

pnpm run lint, pnpm run test-unit clean.

LexicalContentEditable.tsx imports useLayoutEffect straight from React and
calls it in Placeholder, so rendering a ContentEditable with a placeholder
on the server logs "useLayoutEffect does nothing on the server" on every
pass.

The package already ships shared/useLayoutEffect.ts for this, which falls
back to useEffect when CAN_USE_DOM is false, and the sibling
shared/useCanShowPlaceholder.ts uses it. Import it here too, and drop the
react-hooks/set-state-in-effect disable that the rule no longer reports
(same as useCanShowPlaceholder, which sets state in the shimmed effect
without one).

No behavioural change in the browser: CAN_USE_DOM is true there, so the
shim is useLayoutEffect.
@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 Aug 2, 2026
@vercel

vercel Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 2, 2026 9:54am
lexical-playground Ready Ready Preview Aug 2, 2026 9:54am

Request Review

@etrepum
etrepum added this pull request to the merge queue Aug 2, 2026
Merged via the queue into meta:main with commit a933222 Aug 2, 2026
48 checks passed
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — fcec01b1 Deployed Aug 2, 2026 by vercel[bot]
Preview – lexical-playground — fcec01b1 Deployed Aug 2, 2026 by vercel[bot]
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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants