Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
useMemo
useMemo는 비용이 큰 계산 결과를 메모이제이션하여 불필요한 재계산을 방지합니다.filters가 변경될 때만 새로운 객체를 생성합니다filters가 동일하면 이전 객체를 재사용하여useFetch훅의 불필요한 재실행을 방지합니다객체 참조가 안정적으로 유지되어 자식 컴포넌트의 불필요한 리렌더링을 방지합니다
복잡한 계산이 필요한 경우
객체나 배열을 생성하는 경우 (참조 동일성 유지)
props로 전달되는 값이 자식 컴포넌트의 리렌더링을 유발할 수 있는 경우
useCallback
useCallback은 함수를 메모이제이션하여 함수 참조를 안정적으로 유지합니다.함수가 props로 전달될 때 참조가 변경되지 않아 자식 컴포넌트의 불필요한 리렌더링을 방지합니다
MovieFilter,MovieList,MovieModal컴포넌트에 안정적인 함수 참조를 제공합니다의존성 배열에 포함된 값이 변경될 때만 새로운 함수를 생성합니다
자식 컴포넌트에 함수를 props로 전달하는 경우
React.memo로 감싼 컴포넌트에 함수를 전달하는 경우다른 훅의 의존성 배열에 함수를 포함하는 경우
성능 최적화 효과
이 프로젝트에서
useCallback과useMemo를 사용함으로써:axiosRequestConfig가 안정적으로 유지되어 불필요한 API 호출을 방지합니다