Skip to content

Commit

Permalink
[Simplyfy] console log, 주석 삭제 #32
Browse files Browse the repository at this point in the history
why
불필요한 주석으로 읽기 좋지 않음

how
주석 console삭제
  • Loading branch information
WooYeonSeo committed Nov 25, 2019
1 parent 96c6e09 commit d6b1a03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 2 additions & 5 deletions client/src/composition/Feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const OFFSET = 3;
const FeedContainer = () => {
const [feeds, setFeeds] = useState<IFeed[]>([]);
const [cursor, setCursor] = useState<string>('9999-12-31T09:29:26.050Z');
const [isLoading, setIsLoading] = useState<boolean>(false);

const checkEnd = useScrollEnd();
// hooks 에서 useQuery 1 부터 시작
const { loading, data, fetchMore } = useQuery<Feeds, FeedVars>(GET_FEEDS, {
Expand All @@ -42,8 +42,6 @@ const FeedContainer = () => {
checkEndFeed();
}, [checkEnd]);

const target = useRef<HTMLElement>(null);

const fetchMoreFeed = async () => {
const { data: value } = await fetchMore({
variables: {
Expand All @@ -67,9 +65,8 @@ const FeedContainer = () => {
setFeeds([...feeds, ...value.feeds]);
};

const checkEndFeed = () => {
const checkEndFeed = (): void => {
fetchMoreFeed();
return null;
};

return (
Expand Down
8 changes: 3 additions & 5 deletions client/src/hooks/useScrollEnd.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect } from 'react';
const useScrollEnd = () => {
// state를 생성합니다.
const [state, setState] = useState(false);
Expand All @@ -9,16 +9,14 @@ const useScrollEnd = () => {
document.documentElement.clientHeight ===
document.documentElement.scrollHeight
) {
console.log("scroll Y : ", window.scrollY);
setState(true);
} else {
console.log("scroll Y! : ", window.scrollY);
setState(false);
}
};
useEffect(() => {
window.addEventListener("scroll", onScroll);
return () => window.removeEventListener("scroll", onScroll); // <---- 집중 !!!
window.addEventListener('scroll', onScroll);
return () => window.removeEventListener('scroll', onScroll);
}, []);
return state;
};
Expand Down

0 comments on commit d6b1a03

Please sign in to comment.