mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
Merge pull request #1376 from YousefED/patch-1
Allow passing of DependencyList to useEditor
This commit is contained in:
commit
47bfd89b83
@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, DependencyList } from 'react'
|
||||
import { EditorOptions } from '@tiptap/core'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
@ -8,7 +8,7 @@ function useForceUpdate() {
|
||||
return () => setValue(value => value + 1)
|
||||
}
|
||||
|
||||
export const useEditor = (options: Partial<EditorOptions> = {}) => {
|
||||
export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
|
||||
const [editor, setEditor] = useState<Editor | null>(null)
|
||||
const forceUpdate = useForceUpdate()
|
||||
|
||||
@ -22,7 +22,7 @@ export const useEditor = (options: Partial<EditorOptions> = {}) => {
|
||||
return () => {
|
||||
instance.destroy()
|
||||
}
|
||||
}, [])
|
||||
}, deps)
|
||||
|
||||
return editor
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user