diff --git a/.changeset/eleven-cycles-kneel.md b/.changeset/eleven-cycles-kneel.md new file mode 100644 index 0000000000..551eea7b7b --- /dev/null +++ b/.changeset/eleven-cycles-kneel.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Use extended `Editor` type in `useSlateWithV` return type diff --git a/docs/libraries/slate-react/hooks.md b/docs/libraries/slate-react/hooks.md index 358655b607..7dde48dbf3 100644 --- a/docs/libraries/slate-react/hooks.md +++ b/docs/libraries/slate-react/hooks.md @@ -28,15 +28,15 @@ Get the current `selected` state of an element. ### Editor hooks -#### `useSlate(): ReactEditor` +#### `useSlate(): Editor` Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor. -#### `useSlateWithV(): { editor: ReactEditor, v: number }` +#### `useSlateWithV(): { editor: Editor, v: number }` The same as `useSlate()` but includes a version counter which you can use to prevent re-renders. -#### `useSlateStatic(): ReactEditor` +#### `useSlateStatic(): Editor` Get the current editor object from the React context. A version of useSlate that does not re-render the context. Previously called `useEditor`. diff --git a/packages/slate-react/src/hooks/use-slate.tsx b/packages/slate-react/src/hooks/use-slate.tsx index ff493588cb..27e84e7713 100644 --- a/packages/slate-react/src/hooks/use-slate.tsx +++ b/packages/slate-react/src/hooks/use-slate.tsx @@ -34,7 +34,7 @@ export const useSlate = (): Editor => { return editor } -export const useSlateWithV = () => { +export const useSlateWithV = (): { editor: Editor; v: number } => { const context = useContext(SlateContext) if (!context) {