From 9e47b22833f137a963087ed127cc07e89cb917a4 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Fri, 21 Jun 2024 11:19:10 +0300 Subject: [PATCH] waxview ref --- wax-prosemirror-core/src/WaxView.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js index b67794884..2900eff71 100644 --- a/wax-prosemirror-core/src/WaxView.js +++ b/wax-prosemirror-core/src/WaxView.js @@ -1,4 +1,5 @@ -import React, { useCallback, useEffect, useRef } from 'react'; +/* eslint-disable consistent-return */ +import React, { useCallback } from 'react'; import styled from 'styled-components'; import ComponentPlugin from './ComponentPlugin'; import './styles/styles.css'; @@ -19,21 +20,19 @@ const WaxOverlays = ComponentPlugin('waxOverlays'); const WaxView = props => { const main = useWaxView(props); - const divRef = useRef(null); - - const initializeWaxView = useCallback(() => { - if (divRef.current) { - divRef.current.replaceChildren(main?.dom); - } - }, [main]); - - useEffect(() => { - initializeWaxView(); - }, [initializeWaxView]); + const waxRef = useCallback( + node => { + if (node) { + node.replaceChildren(main?.dom); + return node; + } + }, + [main], + ); return ( <EditorContainer> - <div ref={divRef} /> + <div ref={waxRef} /> <WaxOverlays activeViewId="main" group="main" /> <WaxPortals /> </EditorContainer> -- GitLab