Skip to content

I love it! 🙌 Question about dollar-sign prefixes #1800

Answered by zurfyx
Tomburgs asked this question in Q&A
Discussion options

You must be logged in to vote

To expand on the why:

Originally, Lexical didn't have $ functions, instead these functions were provided to you through callback params:

// Mid 2020 API
editor.update((viewState) => {
  const getRoot = viewState.getRoot();
  ..
});
editor.addTextTransform((viewState) => {
  const getRoot = viewState.getRoot();
  ..
});

Internally, this approach raised some negative feedback:

  1. The viewState terminology was confusing. It wasn't really a viewState, more like a toolkit to manipulate the EditorState
  2. For complex updates and transforms devs had to carry params around on many layers

This is when we decided to leverage the "lexical" scope instead to perform EditorState manipulation, and the $ re…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Tomburgs
Comment options

Answer selected by thegreatercurve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants