-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: 용어집 무한스크롤 #136
base: main
Are you sure you want to change the base?
feat: 용어집 무한스크롤 #136
Conversation
|
…he IntersectionObserver.
…re, useIntersectionObserver was changed to return ref
src/hooks/useIntersectionObserver.ts
Outdated
|
||
useEffect(() => { | ||
const node = ref?.current; // DOM Ref | ||
const hasIOSupport = !!window.IntersectionObserver; |
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.
intersection-observer
플러그인을 import 해주셔서 폴리필 미지원으로 인한 이슈는 없을 것 같은데 해당 조건이 필요한 케이스가 있을까용?
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.
없을 것으로 보입니다! 제거하는게 좋아보입니다!
return { ref, entry }; | ||
} | ||
|
||
export default useIntersectionObserver; |
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.
so 깔끔한 훅이네요! 굿굿
src/hooks/useIntersectionObserver.ts
Outdated
const ref = useRef<HTMLFormElement | null>(null); | ||
const [entry, setEntry] = useState<IntersectionObserverEntry>(); | ||
|
||
const frozen = entry?.isIntersecting && freezeOnceVisible; |
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.
boolean type 지정이 있으면 좋을 것 같아요!
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.
넵! 타입지정!
const startIdx = 0; | ||
const endIdx = currentOffest; | ||
return source.slice(startIdx, endIdx); | ||
}; |
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.
타입 지정되면 좋을 것 같아요~
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.
넵! 타입지정!
src/hooks/useInfiniteScroll.ts
Outdated
@@ -0,0 +1,34 @@ | |||
import { useEffect, useState } from 'react'; | |||
|
|||
const usePagination = ({ source = [], limit = 10, offset = 0 }) => { |
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.
Prop에 대해 interface를 정의하고 각 prop에 대한 설명이 있으면 좋을 것 같아요 :)
interface Props {
source
limit
offset
}
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.
이부분은 생각지 못했는데 감사합니다! 설명!
src/hooks/useInfiniteScroll.ts
Outdated
return source.slice(startIdx, endIdx); | ||
}; | ||
|
||
const getMaxOffset = () => { |
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.
return type도 명시되면 좋을 것 같습니다 ㅎㅎ
const getMaxOffset = () => { | |
const getMaxOffset = (): number => { |
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.
넵! 타입지정!!!@!
src/hooks/useInfiniteScroll.ts
Outdated
return source.length; | ||
}; | ||
|
||
const [currentOffest, setCurrentOffest] = useState(limit); |
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.
state generic에는 type 지정을 해주는 게 좋아요 :) 지금은 limit 값으로 초기화를 해줘서 typescript가 setCurrentOffest() 함수를 썼을 때 number 타입 이외에 다른 값이 들어가지 않게 추론을 해주긴 하지만 IDE 환경에 의존해야 하는 부분이 있거든요. 초기화를 안했을 경우에는 어떤 타입으로 할당해야 하는지 추론이 안되구요 ㅎㅎ 그래서 일관성을 위해 다음처럼 작성하면 좋습니당!
const [currentOffest, setCurrentOffest] = useState(limit); | |
const [currentOffest, setCurrentOffest] = useState<number>(limit); |
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.
넵! 타입지정을 자꾸 빼먹고 작성을하게 되네용! 꼭 기억하겠습니다!
{...word} | ||
last={getLastRow(index)} | ||
onNext={onNext} | ||
/> |
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.
layer tree가 업데이트 될 때마다 table의 width 값이 계속 바뀌네요 ㅎㅎㅠ 새로 추가되는 콘텐츠에 따라 기존에 있던 table의 너비가 달라지니 당연한 거긴 한데 사용자 경험 측면에서 자연스럽지 않아 보이는군요.. 반응형을 생각했을 때 table 구조가 용어 사전을 보기에 적절한 UI인지도 논의가 필요할 것 같아요
2021-10-08.8.45.00.mov
.
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.
아하 영상보고 이해가 되었습니다! 이부분은 적절한 UI로 변경되야될것으로 보이네요!
"layer tree가 업데이트 될 때마다 table의 width 값이 계속 바뀌네요" 이슈 제외하고 모두 처리 완료했습니다. |
Description
용어집 무한스크롤 구현
Help Wanted 👀
무한 스크롤 시점을 체크하는 마지막 요소에서 ref를 넣어 줍니다. 이때 3항 연산자를 통하여 넣어주도록 구현했습니다.
이부분을 더 깔끔하게 구현해보고자 여러 다르게 구현했지만 상위에 ref를 위한 테그를 만들거나 더 지저분해지는 느낌이 있어서
더 좋게, 더 깔끔하게 할 수 있는 아이디어가 있을까요?
Related Issues
resolve #109
fix #
Checklist ✋
yarn build
)