Skip to content

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 ​

ParameterTypeDefault value
editorEditorundefined
selector(snapshot) => Tundefined
isEqual?(a, b) => booleanObject.is

Returns ​

Readonly<ShallowRef<T>>

Example ​

ts
const isBold = useEditorState(editor, (s) => s.marks.has('bold'))