From 80858f53d95d91ffc8d5c50f9b04f6a1081ab4de Mon Sep 17 00:00:00 2001 From: Artemy Date: Sat, 29 Apr 2023 09:35:15 +0300 Subject: [PATCH] fix: text updating in edit --- src/pages/note.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/note.jsx b/src/pages/note.jsx index e8e6564..b0e9ceb 100644 --- a/src/pages/note.jsx +++ b/src/pages/note.jsx @@ -37,6 +37,8 @@ function NotePage() { let note = notes[params.id]; let [edit, setEdit] = useState(false); + let [text, setText] = useState(note.text); + let [name, setName] = useState(note.name); return (
@@ -52,17 +54,17 @@ function NotePage() { <> (note.name = e.target.value)} + onChange={(e) => setName(e.target.value)} /> (note.text = e.target.value)} + onChange={(e) => setText(e.target.value)} />
{ - note.text = text; + setText(text); }} />
@@ -81,11 +83,12 @@ function NotePage() { text={locals.Edit} icon={PencilIcon} onClick={() => { - setEdit(!edit); + notes[params.id].name = name; + notes[params.id].text = text; - if (edit) { - localStorage.setObj("Notes", notes); - } + localStorage.setObj("Notes", notes); + + setEdit(!edit); }} /> {!edit && (