Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment-07: 한슬희 #3

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

hanseulhee
Copy link
Member

@hyesungoh hyesungoh self-requested a review June 22, 2022 12:27
() => setTextState("정보가 확인됐어요 :D"),
8000
);
return () => clearTimeout(timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍 👍 👍

if (clock) {
clock.innerText = `${currentHour} : ${currentMinutes} : ${currentSecond}`;
}
setInterval(Clock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 지정해주시면, 계속 실행되는 시간인 delay시간이 0으로 설정돼요!

https://developer.mozilla.org/en-US/docs/Web/API/setInterval#parameters


추가적으로 현재 인터벌을 통해 매번 컴포넌트를 다시 렌더링하고 있는데, 이런 패턴은 불필요한 실행까지 있을 수 있는 안티패턴으로 보여요!

인터벌을 이용해 setState하는 방향으로 수정해보시면 좋을 거 같아요~ 👍 👍 👍 👍 👍 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 추가적으로 interval도 timeout처럼 clear하실 수 있으니 그런 방향으로 해보시면 좋을 거 같아요 ~!

@@ -0,0 +1,21 @@
function Clock() {
const clock = document.querySelector<HTMLSpanElement>(".clock");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리액트에서 쿼리 셀렉터를 사용하는 것은 지양하시는 것이 좋아요!

그 대신 ref에 대해 공부해보시면 좋을 거 같아요 ~~~! 👍 👍

https://ko.reactjs.org/docs/hooks-reference.html#useref

Comment on lines +6 to +7
const currentMinutes = String(currentTime.getMinutes()).padStart(2, "0");
const currentSecond = String(currentTime.getSeconds()).padStart(2, "0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 getMinutes, getSeconds를 사용하시지 않고, padStart를 사용하신 이유가 있을까요???

궁금해요 ~~~~ 👍 👍 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분이나 초가 한자릿수일 경우 앞에 0을 붙이기 위해 사용하였습니당

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

허걱 그런 이유가 ~~~~ 👍 👍 👍
여기에서 추가적으로 함수로 빼서 관리할 수도 있을 거 같네요 고럼!!! 👍 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

허걱 고럼 좋겠네요 ~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants