codestates / codestates/BookDam
22.01.12 Dev-Log
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
### 오늘은 어떻게 프로젝트에 기여했나요?
- SentenceModal, MyPage 서버 통신 확인 및 기능 구현 중
### 오늘의 프로젝트에서 힘든 점은 무엇인가요?
- MyPage에서 내 모든 정보를 조회하는데 값을 계속 불러와서 무한 렌더링에 걸렸습니다.
이유는 알지 못했지만 async로 진행했던 것을 setTimeout 함수를 적용해서 해결했습니다.
<오류 코드>
```js
const getMyInfoAll = useCallback(async() => {
setLoading(true)
await axios
.get(`http://localhost:4000/user/${userInfo.id}?page=${page}`,
{
headers: { 'Content-Type': 'application/json' }
})
.then((res) => {
console.log(res.data)
setMyArticleList(myArticleList => [...myArticleList, ...res.data.articleData.rows])
setMyUserInfo({
id: res.data.userInfo.id,
userId: res.data.userInfo.userId,
userNickName: res.data.userInfo.userNickName,
userImage: res.data.userInfo.userImage
})
setFollow({
following: res.data.follow.following,
follower: res.data.follow.follower
})
})
setLoading(false)
}, [page])
```
<해결방법>
```js
//내 전체 정보 조회하는 함수 (무한 스크롤 적용)
const getMyInfoAll = useCallback(() => {
setLoading(true)
setTimeout(() => {
axios
.get(`http://localhost:4000/user/${userInfo.id}?page=${page}`,
{
headers: { 'Content-Type': 'application/json' }
})
.then((res) => {
console.log(res.data)
setMyArticleList(myArticleList => [...myArticleList, ...res.data.articleData.rows])
setMyUserInfo({
id: res.data.userInfo.id,
userId: res.data.userInfo.userId,
userNickName: res.data.userInfo.userNickName,
userImage: res.data.userInfo.userImage
})
setFollow({
following: res.data.follow.following,
follower: res.data.follow.follower
})
})
}, 1000)
setLoading(false)
}, [page])
```
### 내일은 프로젝트에 기여하기 위해 무엇을 해야 하나요?
- [ ] SentenceModal 기능 중 편집, 삭제 기능 구현
- [ ] UserModifyModal의 정상적인 통신이 가능하지 확인
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.