[6주차] Team 엔젤브릿지 권혜인 & 이가빈 미션 제출합니다.#11
[6주차] Team 엔젤브릿지 권혜인 & 이가빈 미션 제출합니다.#11billy0904 wants to merge 69 commits intoCEOS-Developers:mainfrom
Conversation
[ Landing ] Landing page 구현
[ Home ] 메인 페이지 구현
Fix: deployerror
검색 및 디테일 페이지 구현
fix: fix deploy bug
fix: fix deploy error
|
이번 코드 리뷰 맡은 박지수입니다!! |
hiwon-lee
left a comment
There was a problem hiding this comment.
이번주도 멋진 과제 하느라 수고하셨습니다
역시 key question도 너무나 정리를 잘 해주신것 같아서 보면서 많이 배워갈 수 있었습니다ㅎㅎ
이제 커리상 프론트 단독으로하는 과제는 다음주가 마지막이더라구요 마지막까지 파이팅~~
| interface Movie { | ||
| id: number; | ||
| title: string; | ||
| poster_path: string; | ||
| } |
There was a problem hiding this comment.
따로 movieInterface.ts를 만든 것을 쓰면 더 좋을것같아요~~
| import { fetchMovies } from '@/api/MovieList'; | ||
| import * as styles from '@/styles/MovieList.css'; | ||
|
|
||
| // 와 진짜 레전드 노가다 |
| import { useSearchStore } from "@/utils/search/useStore"; | ||
| import { fetchSearch } from "@/api/searchApi"; | ||
|
|
||
| export const ContentList: React.FC = () => { |
There was a problem hiding this comment.
vanilla-extract쓰는거 처음봤어요!!
저번에 혜인언니랑 집갈때 제가 관련라이브러리 정리한거 있다고 한 거 찾았어요
허접하긴한데,, 그냥 정리겸 ㅎㅎ
- tailwind
- styled component or emotion -> Server Component SSR 문제가 되고 있다.
- sass
- css module -> 간단하게 가자
- vanilla extact -> windows와 문제가 생길 수 있음 (요즘 핫함)
There was a problem hiding this comment.
윈도우에서 css 적용 안되는 문제는 해결되었다고 듣긴 했는데 문제가 또 생긴 건가요🥹🥹 우리 둘다 윈도우 쓰는데... 찾아봐야겠다....
billy0904
left a comment
There was a problem hiding this comment.
바쁜 와중에도 빠른 속도로 뚝딱뚝딱 너무 잘 구현해줘서 고마워용💚🌟 내 파트너가 짱임... 엔브도 같이 즐겁게 달려봅시다 ㅎㅎ
이번 주차 과제도 수고하셨습니다!🍀
| import { Movie } from "@/types/movieInterface"; | ||
| import { instance } from "./instance"; | ||
|
|
||
| interface FetchMoviesResponse { | ||
| results: Movie[]; | ||
| } | ||
|
|
||
| export const fetchSearch = async (page: number = 1): Promise<Movie[]> => { | ||
| const response: FetchMoviesResponse = await instance.get( | ||
| `/movie/popular?api_key=${process.env.NEXT_PUBLIC_API_KEY}&language=en-US&page=${page}`, | ||
| ); | ||
| return response.results; | ||
| }; |
There was a problem hiding this comment.
API 관련 파일은 이 파일처럼 어쩌구Api로 이름을 통일시키는게 좋을 것 같네요! 아무 생각 없었는데 언니 파일명 보고 생각남..ㅎ
| import Image from "next/image"; | ||
| import { fetchSearch } from "@/api/searchApi"; | ||
|
|
||
| const IMAGE_BASE_URL = "https://image.tmdb.org/t/p/w500/"; |
| import { useSearchStore } from "@/utils/search/useStore"; | ||
| import { fetchSearch } from "@/api/searchApi"; | ||
|
|
||
| export const ContentList: React.FC = () => { |
| const fetchMovies = useCallback(() => { | ||
| const fetchData = async () => { | ||
| try { | ||
| const data = await fetchSearch(1); | ||
| const filteredData = searchText | ||
| ? data.filter((movie) => | ||
| movie.title.toLowerCase().includes(searchText.toLowerCase()), | ||
| ) | ||
| : data; | ||
| setMovies(filteredData); | ||
| } catch (error) { | ||
| console.error("검색리스트 실패", error); | ||
| } | ||
| }; | ||
| fetchData(); | ||
| }, [searchText]); | ||
|
|
||
| useEffect(() => { | ||
| fetchMovies(); | ||
| }, [searchText]); |
There was a problem hiding this comment.
실시간 검색은 이렇게 구현하는거군요...!! 코드 보면서 많이 배워갑니다~!👍💚
| <Image | ||
| style={{ cursor: "pointer" }} | ||
| className={style.icon} | ||
| src={cancelIcon} | ||
| alt="검색취소" | ||
| onClick={cancelSearch} | ||
| /> |
🍀배포 링크
무한 스크롤과
Intersection Observer API의 특징에 대해 알아봅시다.무한 스크롤 (Infinite Scroll)
장점
단점
Intersection Observer API (교차 관찰자 API)
addEventListener()의scroll과 같은 이벤트 기반의 요소 관찰에서 발생하는 렌더링 성능이나 이벤트 연속 호출같은 문제 없이 사용할 수 있다.🥲기존
scroll의 문제점
- 각 요소마다 이벤트가 등록되어있는 경우 사용자가 스크롤할 때마다 이벤트가 끊임없이 호출되기 떄문에 몇 배로 성능 문제가 발생한다.
💡scroll이벤트의 경우 단시간에 수백번 호출이 되며 동기적으로 실행된다.getBoundingClientRect()역시 계산을 할 때마다 리플로우 현상이 일어난다는 단점이 있다.리플로우 (reflow)
🌟사용 방법
✅ 기본 문법
new IntersectionObserver()를 통해 생성한 인스턴스io로 관찰자를 초기화하고 관찰할 요소를 지정한다.callback과options두 개를 갖는다.✅ Callback
entries와observer두 개를 갖는다.✅ entries
IntersectionObserverEntry는 읽기 전용의 여러가지 속성들을 포함한다.boundingClientRect: 관찰 대상의 사각형 정보([DOMRectReadOnly](https://developer.mozilla.org/en-US/docs/Web/API/[DOMRectReadOnly](https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly)))intersectionRect: 관찰 대상의 교차한 영역 정보(DOMRectReadOnly)intersectionRatio: 관찰 대상의 교차한 영역 백분율(intersectionRect영역에서boundingClientRect영역까지 비율, Number)isIntersecting: 관찰 대상의 교차 상태(Boolean)rootBounds: 지정한 루트 요소의 사각형 정보([DOMRectReadOnly](https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly))target: 관찰 대상 요소([Element](https://developer.mozilla.org/en-US/docs/Web/API/Element))time: 변경이 발생한 시간 정보([DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp))✅ observer
✅ options
root,rootMargin,threshold세 가지 값을 옵션 값으로 설정할 수 있다.tanstack query의 사용 이유(기존의 상태 관리 라이브러리와는 어떻게 다른지)와 사용 방법(reactJS와 nextJS에서)을 알아봅시다.Tanstack Query
useQuery훅을 사용하여 서버에 필요한 데이터를 비동기적으로 요청한다.✅ 상태 관리 라이브러리 vs. tanstck query
📍상태 관리 라이브러리
📍tanstck query
✅ 기술적 장점
1️⃣ 데이터 캐싱 및 재사용
useQuery훅을 사용하여 데이터를 호출했을 때 동일한queryKey로 호출한 기록이 존재한다면 캐시되어있던 해당 데이터를 재사용하고, 그렇지 않을 경우queryFn을 호출하여 새롭게 데이터를 받아온다.2️⃣ 간편한 상태 관리
useQuery훅을 통한 비동기 요청의 로딩(isLoading, isPending), 성공(data), 실패(isError, error) 등의 상태를 제공한다.3️⃣ 서버 사이드 렌더링 (SSR) 지원
4️⃣ 낙관적 업데이트 (optimistic update)
🌟사용 방법
✅ React.js
📍기본 설치
ReactQueryProvider를 컴포넌트 트리의 루트에 배치ReactQueryProvider적용📍useQuery
📍useSuspenseQuery
📍useMutation
📍useQueries
✅ Next.js
📍기본 설치
📍useQuery
📍useSuspenseQuery
useQuery의suspense:true옵션으로 사용했는데 v5 부터는useSuspenseQuery를 통해 suspense와 사용할 수 있다.📍useMutation
📍useQueries
[queryResult.data](http://queryresult.data/)로 사용할 수 있다.기본적인 git add, commit, push, pull, merge, rebase 등의 명령어에 대해 알아봅시다(+ git branch 전략이나 다른 git 명령어도 좋습니다!)
✅ git add
✅ git commit
✅ git push
✅ git fetch
✅ git pull
✅ git merge
✅ git rebase
(+) ETC…
git status: 현재 상태를 확인(스테이징된 파일, 변경된 파일, 트랙되지 않은 파일 등)git log: 커밋 기록 확인git branch: 브랜치 목록 확인 및 생성/삭제git reset: 이전 상태로 되돌림(스테이징 또는 커밋 제거)