Merge pull request #1376 from YousefED/patch-1

Allow passing of DependencyList to useEditor
This commit is contained in:
Philipp Kühn 2021-05-26 08:56:07 +02:00 committed by GitHub
commit 47bfd89b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}