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

View File

@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react' import { useState, useEffect, DependencyList } from 'react'
import { EditorOptions } from '@tiptap/core' import { EditorOptions } from '@tiptap/core'
import { Editor } from './Editor' import { Editor } from './Editor'
@@ -8,7 +8,7 @@ function useForceUpdate() {
return () => setValue(value => value + 1) 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 [editor, setEditor] = useState<Editor | null>(null)
const forceUpdate = useForceUpdate() const forceUpdate = useForceUpdate()
@@ -22,7 +22,7 @@ export const useEditor = (options: Partial<EditorOptions> = {}) => {
return () => { return () => {
instance.destroy() instance.destroy()
} }
}, []) }, deps)
return editor return editor
} }