<aside> 📁 목차
![[단디] 배너.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/109365fb-7596-46f0-90c8-8c2f07ed3600/bf25891c-089d-4542-a68c-0f083012462d/%E1%84%83%E1%85%A1%E1%86%AB%E1%84%83%E1%85%B5_%E1%84%87%E1%85%A2%E1%84%82%E1%85%A5.png)
꾸준히 일기를 작성하고 싶은 사람을 위한 일기 작성 플랫폼
마지막 함수가 호출된 후 일정 시간 동안 함수가 호출되지 않게 하는 방법
화면 기록 2023-12-07 오전 4.39.47.mov
function App() {
const [textList, setTextList] = useState<string[]>([]);
const [throttle, setThrottle] = useState(false);
const throttling = (e) => {
if (throttle) return;
setThrottle(true);
setTimeout(() => {
setTextList([...textList, e.target.value]);
setThrottle(false);
}, 500);
};
return (
<>
<div className="App">
<div className="inputDiv">
<label htmlFor="testInput">아무 말이나 입력하세요!</label>
<input name="testInput" type="text" onChange={throttling} />
</div>
{textList.map((text, index) => (
<p key={index}>{text}</p>
))}
</div>
</>
);
}