Initial editorState null vs undefined is hard to discover #4269
alex-sherwin
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Not really a bug, since I finally stumbled across the fact this was intentional...
What happened for me was that I wanted to start with an empty editor, so I just used
nullas the initial editor state passed toLexicalComposer, not realizing that it supportsnull | undefinedin the overall type union.But it's very much not obvious unless you happen to either debug/trace through the source or happen to stumble on the collab page: https://lexical.dev/docs/collaboration/react which describes the difference of null vs undefined
It would be nice if this was more explicitly called out somehow.. or better, in my opinion, if there was a different way to represent an initial config that should be empty versus "do nothing" (what collab needs), since both null and undefined are arguably two ways to represent the absense of a value
If you wanted to get super pedantic you could argue the current logic is backwards, where undefined would be the absence of value (meaning "do nothing"), where null is the presence of a specific value (null), which would mean an empty initial state
Beta Was this translation helpful? Give feedback.
All reactions