Skip to content

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 ​

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

Returns ​

T

Example ​

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