mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
Use extended Editor
type in useSlateWithV
return type (#5763)
* Use extended `Editor` type in `useSlateWithV` return type So it matches the return types of `useSlate` and `useSlateStatic`. The `useSlateWithV` return object's `editor` property is currently typed as just a `ReactEditor`, which causes type errors in our app when we try to use it as the extended `Editor` type. * Fix return types in "Editor hooks" docs
This commit is contained in:
5
.changeset/eleven-cycles-kneel.md
Normal file
5
.changeset/eleven-cycles-kneel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Use extended `Editor` type in `useSlateWithV` return type
|
@@ -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`.
|
||||
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user