From ab0dd09497c9a5ab782944fa85e437c90fd841e5 Mon Sep 17 00:00:00 2001 From: Michael Chung <6252325+ArEnSc@users.noreply.github.com> Date: Sat, 23 Mar 2024 23:10:57 -0400 Subject: [PATCH] fixed dupe canvas add --- app/pages/PageEnigma/PageEnigma.tsx | 17 ++++------------- app/pages/PageEnigma/js/editor.js | 1 + 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/pages/PageEnigma/PageEnigma.tsx b/app/pages/PageEnigma/PageEnigma.tsx index 1a1efaf667..db092321f8 100644 --- a/app/pages/PageEnigma/PageEnigma.tsx +++ b/app/pages/PageEnigma/PageEnigma.tsx @@ -30,26 +30,17 @@ export const PageEnigma = () => { const canvasRef = useRef(null); const editorRef = useRef(null); - const editorCallback = useCallback(() => { // handle editorCallback here },[]); useEffect(() => { //componentDidMount - editorRef.current = new Editor(); - function init(){ - if(editorRef.current!==null){ - //TODO: init with editorRef.current.initialize(editorCallback); - editorRef.current.initialize(); - } - } - - if(canvasRef!==null){ - init(); - }else{ - setTimeout(init, 500); + if (editorRef.current == null) { + editorRef.current = new Editor(); + editorRef.current.initialize(); } + }, []); const handleButtonSave = ()=>{ diff --git a/app/pages/PageEnigma/js/editor.js b/app/pages/PageEnigma/js/editor.js index d56f66eb4f..b124caf323 100644 --- a/app/pages/PageEnigma/js/editor.js +++ b/app/pages/PageEnigma/js/editor.js @@ -31,6 +31,7 @@ class Editor { // Default params. constructor() { + console.log("If you see this message twice! then it rendered twice, if you see it once it's all good.") // For making sure the editor only gets created onece. this.can_initailize = false; let one_element = document.getElementById("created-one-element");