Function: useEditorState()
ts
function useEditorState<T>(
editor,
selector,
isEqual?
): T;Read part of the editor state and re-render only when it changes.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value |
|---|---|---|
editor | Editor | undefined |
selector | (snapshot) => T | undefined |
isEqual? | (a, b) => boolean | Object.is |
Returns
T
Example
tsx
const isBold = useEditorState(editor, (s) => s.marks.has('bold'))
const canUndo = useEditorState(editor, (s) => s.canUndo)