lexical icon indicating copy to clipboard operation
lexical copied to clipboard

[lexical] Chore: make unable to find active editor state error more descriptive about potential dependency issue

Open AlessioGr opened this issue 1 year ago • 2 comments

This error message can be kinda similar to the React hooks error message:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

E.g. If people have multiple versions of lexical installed, where the lexical editor is initialized by one version of lexical, but their own custom nodes are initialized by a different version, this error message will occur.

This happens to SO many people after they upgrade my package and forget to make sure their lexical version matches the one which my package is using.

Adding this hint to the error message will give them a chance to figure out why this might be happening

AlessioGr avatar Apr 30 '24 22:04 AlessioGr

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:33pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:33pm

vercel[bot] avatar Apr 30 '24 22:04 vercel[bot]

If it happens often to the users of your library - may I ask if you place Lexical as dependency or peerDependency in package.json? It shall be the latter with range of versions supported

StyleT avatar May 01 '24 22:05 StyleT