"use client";
import { useEffect, useState } from "react";
const Reply = ({ id }) => {
const [reply, setReply] = useState("");
const [replyData, setRD] = useState([]);
const sendReply = () => {
fetch("/api/reply/create", {
method: "POST",
body: JSON.stringify({ reply: reply, id: id }),
}).then((req, res) => console.log(req.status));
setReply("");
};
useEffect(() => {
fetch(`/api/reply/load?id=${id}`)
.then((r) => r.json())
.then((result) => console.log(result));
}, []);
return (
<div>
<div>
<div></div>
<input onChange={(e) => setReply(e.target.value)} value={replay}/>
<button
onClick={sendReply}
>
댓글 입력
</button>
</div>
</div>
);
};
export default Reply;
왜 저는 댓글입력하고 버튼눌렀을때 초기화가 안될까요
코드 영상하고 똑같이 입력했을때도 초기화 안되고
혹시 몰라서 input에 value 로 reply 주고 버튼 이벤트를 sendReply로 주고 setReply로 " " 으로 초기화까지 시켜봤는데도 안되네요