codestates / codestates/HoloSulo

[Dev-log] 강범규 - 2022.02.16

Open
#65 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 오늘은 어떻게 프로젝트에 기여했나요?
- https://github.com/codestates/HoloSulo/pull/62

### 오늘의 프로젝트에서 힘든 점은 무엇인가요?
- 콜백함수안에서 최신 state 접근이 안되는 문제.
> useRef사용해 처리했는데 혹시 다른 방법이 있는지 확인 필요
```
useEffect(() => {
audio.addEventListener("ended", () => {
console.log("ended song", currentSongIndex, audio);

audio.pause();
if (!isTimeOver.current) {
songIndex.current = (songIndex.current + 1) % songs.length;
audio.src = songs[songIndex.current].url;
audio.play();
setCurrentSongIndex(songIndex.current);
}
console.log("next song", currentSongIndex, audio);
});
setTimeout(() => {
audio.pause();
// play ending song
audio.src = endingSong;
audio.play();
isTimeOver.current = true;
setIsModalOpened(true);
}, time);
return () => {
audio.pause();
setAudio(null);
};
}, []);
```

### 내일은 프로젝트에 기여하기 위해 무엇을 해야 하나요?
* [ ] https://github.com/codestates/HoloSulo/issues/63
* [ ] https://github.com/codestates/HoloSulo/issues/64

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.