From 266eb2fec020fc430d0d206f11dc7bd08e5d9dc1 Mon Sep 17 00:00:00 2001 From: HETTski Date: Mon, 12 Aug 2024 20:10:46 +0200 Subject: [PATCH] fixed bug --- src/components/CodeEditor.js | 43 ------------------------------------ 1 file changed, 43 deletions(-) diff --git a/src/components/CodeEditor.js b/src/components/CodeEditor.js index 624ec79..a875091 100644 --- a/src/components/CodeEditor.js +++ b/src/components/CodeEditor.js @@ -27,69 +27,26 @@ const CodeEditor = ({ onExecute, isError }) => { }, [visibleIndex]); // local storage things - const [code, setCode] = useState(() => { - const savedCode = localStorage.getItem("code"); - return savedCode !== null - ? JSON.parse(savedCode) - : ["/* Kod idzie tutaj */"]; - }); - - useEffect(() => { - localStorage.setItem("code", JSON.stringify(code)); - }, [code]); - - const [visibleIndex, setVisibleIndex] = useState(() => { - const savedIndex = localStorage.getItem("visibleIndex"); - return savedIndex !== null ? JSON.parse(savedIndex) : 0; - }); - - useEffect(() => { - localStorage.setItem("visibleIndex", JSON.stringify(visibleIndex)); - }, [visibleIndex]); -// local storage things - - const handleVisibility = (index) => { - setVisibleIndex(index); - }; const handleVisibility = (index) => { setVisibleIndex(index); }; - const handleTextChange = (value, index) => { - const newCode = [...code]; - newCode[index] = value; - setCode(newCode); - }; const handleTextChange = (value, index) => { const newCode = [...code]; newCode[index] = value; setCode(newCode); }; - const handleExecute = () => { - onExecute(code[visibleIndex]); - }; const handleExecute = () => { onExecute(code[visibleIndex]); }; - const addTextarea = () => { - setCode([...code, ""]); - setVisibleIndex(code.length); - }; const addTextarea = () => { setCode([...code, ""]); setVisibleIndex(code.length); }; - const removeTextarea = () => { - if (code.length > 1) { - const newCode = code.slice(0, -1); - setCode(newCode); - setVisibleIndex(newCode.length - 1); - } - }; const removeTextarea = () => { if (code.length > 1) { const newCode = code.slice(0, -1);