Skip to content

Commit

Permalink
Revert "fix: Make sure editor is available on first render (#2282), fix
Browse files Browse the repository at this point in the history
#2040, fix #2182"

This reverts commit 2436e2c.
  • Loading branch information
Philipp Kühn authored and Philipp Kühn committed Dec 17, 2021
1 parent 07cabe6 commit 629f4d2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/react/src/useEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ function useForceUpdate() {
}

export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
const [editor, setEditor] = useState<Editor>(() => new Editor(options))
const [editor, setEditor] = useState<Editor | null>(null)
const forceUpdate = useForceUpdate()

useEffect(() => {
let instance: Editor
const instance = new Editor(options)

if (editor.isDestroyed) {
instance = new Editor(options)
setEditor(instance)
} else {
instance = editor
}
setEditor(instance)

instance.on('transaction', () => {
requestAnimationFrame(() => {
Expand Down

0 comments on commit 629f4d2

Please sign in to comment.