From bdd6e2b87c36a2aa100412a86aaac51af1d47e52 Mon Sep 17 00:00:00 2001 From: Yousef Date: Tue, 25 May 2021 14:51:36 +0200 Subject: [PATCH] Allow passing of DependencyList to useEditor in case the options depend on props of the consuming component, it would be nice to be able to pass a dependencylist to `useEditor`. Unless there's a better way to handle dependency updates --- packages/react/src/useEditor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react/src/useEditor.ts b/packages/react/src/useEditor.ts index 165e52d6..f2f3fcda 100644 --- a/packages/react/src/useEditor.ts +++ b/packages/react/src/useEditor.ts @@ -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 = {}) => { +export const useEditor = (options: Partial = {}, deps: DependencyList = []) => { const [editor, setEditor] = useState(null) const forceUpdate = useForceUpdate() @@ -22,7 +22,7 @@ export const useEditor = (options: Partial = {}) => { return () => { instance.destroy() } - }, []) + }, deps) return editor }