fixed dupe canvas add

This commit is contained in:
Michael Chung committed 2024-03-23 23:10:57 -04:00
1 parent d6cbb3ca90
commit ab0dd09497
2 files changed
+5 -13

No files matched your search

+4 -13
View File
@@ -30,26 +30,17 @@ export const PageEnigma = () => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const editorRef = useRef<Editor | null>(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 = ()=>{
+1
View File
@@ -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");