From 4ea250c3aaf70bba58bdaf63e1b275e4259cb5b5 Mon Sep 17 00:00:00 2001 From: yeji Date: Fri, 13 Nov 2020 15:13:55 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20=EC=9D=B4=EC=8A=88=20=EC=A0=9C=EB=AA=A9?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cancel 버튼 클릭 시에도 제목이 변경되는 문제 해결 prevTitle이라는 상태를 추가 --- .../components/issueDetail/header/index.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/components/issueDetail/header/index.js b/client/src/components/issueDetail/header/index.js index 07ed767..1e8e8cf 100644 --- a/client/src/components/issueDetail/header/index.js +++ b/client/src/components/issueDetail/header/index.js @@ -7,6 +7,7 @@ import S from './style'; const Header = ({ issue, commentsCount }) => { const [isEditClicked, setIsEditClicked] = useState(false); const [title, setTitle] = useState(''); + const [prevTitle, setprevTitle] = useState(''); const dispatch = useIssueDetailDispatch(); @@ -19,12 +20,22 @@ const Header = ({ issue, commentsCount }) => { setIsEditClicked(false); }; + const cancelHandler = () => { + setIsEditClicked(false); + setTitle(prevTitle); + }; + const changeHandler = (e) => { setTitle(e.target.value); }; + const editHandler = () => { + setprevTitle(title); + setIsEditClicked(true); + }; + const editButton = isEditClicked ? null : ( - ); @@ -43,14 +54,7 @@ const Header = ({ issue, commentsCount }) => { - { - setIsEditClicked(false); - }} - value="Cancel" - /> + ) : (