Hooks
React hooks for Slate editors
Get the current
focused
state of the editor.Get the current
readOnly
state of the editor.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.
The same as
useSlate()
but includes a version counter which you can use to prevent re-renders.Get the current editor object from the React context. A version of useSlate that does not re-render the context. Previously called
useEditor
.Get the current editor selection from the React context. Only re-renders when the selection changes.
Similar to
useSlateSelection
but uses redux style selectors to prevent rerendering on every keystroke.Returns a subset of the full selection value based on the
selector
.Bear in mind rerendering can only prevented if the returned value is a value type or for reference types (e.g. objects and arrays) add a custom equality function for the
equalityFn
argument.Example:
const isSelectionActive = useSlateSelector(editor => Boolean(editor.selection))
Last modified 5mo ago