19강 인피니티 스크롤 IntersectionObserver 코드 위치 수정이 필요합니다.
405
1 asked
gatsby develop 시에는 문제가 안되지만, gatsby build 시에 문제가 되는 부분입니다.
참고한 사이트는 아래와 같습니다.
https://stackoverflow.com/questions/59424347/gatsby-intersectionobserver-is-not-defined
마지막 코드 observer 부분은 하기 내용과 같은데
const observer: IntersectionObserver = new IntersectionObserver(
(entries, observer) => {
if (!entries[0].isIntersecting) return;
setCount(value => value + 1);
observer.disconnect();
},
)
useEffect(() => setCount(1), [selectedCategory])
useEffect(() => {
if (
NUMBER_OF_ITEMS_PER_PAGE * count >= postListByCategory.length ||
containerRef.current === null ||
containerRef.current.children.length === 0
)
return
observer.observe(
containerRef.current.children[containerRef.current.children.length - 1],
)
}, [count, selectedCategory])IntersectionObserver 구문을 useEffect 안으로 넣어야 할 것 같습니다.
useEffect(() => setCount(1), [selectedCategory])
useEffect(() => {
const observer: IntersectionObserver = new IntersectionObserver(
(entries, observer) => {
if (!entries[0].isIntersecting) return;
setCount(value => value + 1);
observer.disconnect();
}
)
if (
NUMBER_OF_ITEMS_PER_PAGE * count >= postListByCategory.length ||
containerRef.current === null ||
containerRef.current.children.length === 0
) return
observer.observe(
containerRef.current.children[containerRef.current.children.length - 1]
)
}, [count, selectedCategory])
Answer 1
쿼리오류 Field "thumbnail" must not have a selection...
1
855
1
타입스크립트를 설정할 때 jsxPragma 옵션을 뺀 이유는 무엇인가요?
1
588
1
마지막 배포 부분 질문드립니다!
1
617
1
'[username]/[username].github.io' -> 'username/reponame'
0
339
0
IntersectionObserver deploy( gatsby build) 시 오류(자답)
1
391
1
PostHead.tsx BackgroundImage 동작오류(자답)
1
289
0
썸네일 이미지 제작 및 학습 방법 관련 문의
1
439
1
배포 후 포스트 업로드 방법
1
379
1
배포 질문이요!
1
514
1
gatsby develop 오류
1
934
1
깃허브 레퍼지토리 질문드려요
1
341
1
특정 게시글을 클릭하여 상세 페이지로 넘어가는 과정과 SPA에 관한 질문
1
282
1
Unhandled Runtime Error 가 뜹니다
0
504
2
sign in with GitHub 클릭 시
1
393
3
동작 반복 시 오류
1
350
2
const BackgroundImage 질문
1
210
1
오타 문의
1
300
2
Props로 받아 포스트 데이터 출력하기가 안됩니다.
1
200
1
index.tsx allMarkdownRemark 에러..
0
592
2
스네이크 케이스로 변수명을 짓는 이유
1
248
1
'Tagged Template Literal 방식을 통해 정의한 CSS 적용 방법'에서 발생하는 문제
3
349
2
상단 이미지를 썸네일 사용하지않고 다른 이미지를 쓰고싶습니다
1
281
1
여기까지 했는데 runtime 에러가 발생합니다
2
281
1
index.tsx오류
2
453
1

