Function: useEditorState()
ts
function useEditorState<T>(
editor,
selector,
isEqual?
): Readonly<ShallowRef<T>>;Read part of the editor state as a ref that updates only when the value 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
Readonly<ShallowRef<T>>
Example
ts
const isBold = useEditorState(editor, (s) => s.marks.has('bold'))