Closed suhyeoonn closed 1 month ago
ms
clear
function App() { const [count, setCount] = useState(0) const [delay, setDelay] = useState(1000) const clear = useInterval(() => { setCount(count + 1); }, delay); const handleStop = () => { clear() } const handleDelay = ({target}) => { setDelay(target.value) } return ( <div> <input type="number" value={delay} onChange={handleDelay} /> <button onClick={handleStop}>stop</button> <div> {count} </div> </div> ); }
๐พ Pull Request
1๏ธโฃ Spec
ms
๊ฐ์ด ๋ณ๊ฒฝ๋ ๋๋ง๋ค interval์ด ์ฌ์ค์ ๋๋ฉฐ, ์ปดํฌ๋ํธ๊ฐ ์ธ๋ง์ดํธ๋ ๋ ์๋์ผ๋ก ํ์ด๋จธ๊ฐ ์ ๋ฆฌ๋ฉ๋๋ค.clear
ํจ์๋ฅผ ํธ์ถํ์ฌ ์๋์ผ๋ก ํ์ด๋จธ๋ฅผ ์ค์งํ ์๋ ์์ต๋๋ค.2๏ธโฃ ๋ณ๊ฒฝ ์ฌํญ
3๏ธโฃ ์์ ์ฝ๋
4๏ธโฃ ๊ด๋ จ ๋ฌธ์ (์ ํ ์ฌํญ)