mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 12:41:44 +02:00
Change how Slate context updates and introduce useSlateSelection
hook (#5041)
* Fix DOM selection sync when there are unexpected rerenders * Create a useSlateSelection hook and expose it * update docs * add changeset * Undo the useEffect change and add a useSlateValue method * Use a version counter instead for SlateContext * comment out layout effect prevention for now * Undo useV comparison for now * Change the changeset * Fix lint * Remove the useSlateValue hook * remove some unused imports * Add useSlateWithV to the docs * fix changeset lint * Change changeset to minor instead
This commit is contained in:
@@ -96,10 +96,18 @@ Get the current `selected` state of an element.
|
||||
|
||||
Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor.
|
||||
|
||||
### `useSlateWithV`
|
||||
|
||||
The same as `useSlate()` but includes a version counter which you can use to prevent re-renders.
|
||||
|
||||
### `useSlateStatic`
|
||||
|
||||
Get the current editor object from the React context. A version of useSlate that does not re-render the context. Previously called `useEditor`.
|
||||
|
||||
### `useSlateSelection`
|
||||
|
||||
Get the current editor selection from the React context. Only re-renders when the selection changes.
|
||||
|
||||
## ReactEditor
|
||||
|
||||
A React and DOM-specific version of the `Editor` interface. All about translating between the DOM and Slate.
|
||||
|
Reference in New Issue
Block a user