-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Feature] Study status changing in real time #10
[Feature] Study status changing in real time #10
Conversation
- Study status changing in real time - npm install moment.js and react-moment
src/components/main/StudyGroups.jsx
Outdated
@@ -11,12 +11,13 @@ const StudyGroupsWrapper = styled.div` | |||
align-content: space-between; | |||
`; | |||
|
|||
const StudyGroups = ({ groups }) => ( | |||
const StudyGroups = ({ groups, seconds }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seconds
props를 삭제해주자. 필요없다.
src/components/main/StudyGroups.jsx
Outdated
<StudyGroupsWrapper> | ||
{groups.map((group) => ( | ||
<StudyGroup | ||
key={group.id} | ||
group={group} | ||
seconds={seconds} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도.
useInterval(() => { | ||
setRealTime(Date.now()); | ||
}, 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useInterval
에 대한 테스트를 어떻게 작성해야할까..🤔 (coverage 실패)
|
||
useEffect(() => { | ||
function tick() { | ||
savedCallback.current(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 여기도 coverage fail
}, 1000); | ||
|
||
const isCheckedTimeStatus = () => { | ||
if (realTime - applyEndTime >= 0 || participants.length === personnel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시간이 초과하거나, 참여자의 수가 초과할 경우 마감이라고 표시해주는 것 같아요. 함수로 분리해주는건 어떨까요?
setRealTime(Date.now()); | ||
}, 1000); | ||
|
||
const isCheckedTimeStatus = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isCheckedTimeStatus
는 true 혹은 false만 반환할 것 같은데 실제로는 컴포넌트를 반환하고 있네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음에 true
false
로 반환할려구 했던 함수였는데 컴포넌트로 반환하는걸로 변경 후 함수 이름을 변경하지 못했줬네요..
🚀 구현 목록
interval
를 사용해야 하기 때문에 커스텀useInterval
를 사용한다.리액트 Hooks에서 setInterval을 사용하면 문제가 발생. (제대로 실행이 안됨.)
🤔 추가적으로 진행할 사항들
useInterval
의 테스트를 작성하는 법.. coverage가 100%가 안된다. 😢아니면 이미 구현되어 있는 커스텀 훅을 npm으로 install을 할것인가.(use-interval)
코드를 보니 구현한 방식랑 거의 같음.