feat: 07-Stopwatch 과제 구현 (최병찬)#30
Open
chan-byeong wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 과제 요약
💡 설계 및 고민한 부분
초기에는
setInterval을 통해서 시간을 갱신함. 하지만 setInterval은 콜스택의 영향을 받기 때문에 엄밀한 시간 갱신을 보장하지 못한다. 그래서 콜스택과 독립적이게 일정주기마다 화면을 갱신하는requestAnimationFrame을 활용하여 시간을 갱신하는 것이 더 낫다고 판단하여 수정하였다.setInterval과rAF를 구현할 때 버튼의 이벤트 핸들러 내부에서 관련 기능을 실행/중지 하는 방식으로 구현하였으나,setInterval과rAF는 side-effect이기 때문에 이를useEffect내부에서 관리하는 것이 옳다고 판단하였다. 그래서 deps array에isRunning을 넣은 뒤 useEffect 내부에서 시간을 업데이트하는 기능을 구현하였다.📖 학습한 내용 및 어려웠던 점 (선택)
❓ 질문 사항 (선택)
📸 스크린샷 (선택)