-
Notifications
You must be signed in to change notification settings - Fork 37
[남기연] sprint9 #308
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
Merged
1005hoon
merged 24 commits into
codeit-bootcamp-frontend:Next-남기연
from
Namgyeon:Next-남기연-sprint9
Jan 23, 2025
The head ref may contain hidden characters: "Next-\uB0A8\uAE30\uC5F0-sprint9"
Merged
[남기연] sprint9 #308
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f554999
git 연결
Namgyeon 9b6a5ca
feat: 기본기능 구현
Namgyeon 5569432
feat: favicon추가, font:Pretendard 적용
Namgyeon 2fab846
feat: 검색기능 추가
Namgyeon fba2e36
chors: 배포 코드추가
Namgyeon 8acaf03
chors: 배포 코드추가2
Namgyeon 7cfb7c7
feat: props nickname 기본값 추가
Namgyeon 6becf40
배포 코드 수정
Namgyeon a71f491
배포 코드 수정
Namgyeon ed284bb
배포 코드 수정
Namgyeon badd979
배포 코드 수정
Namgyeon eac3d41
배포 오류 수정을 위해 파일경로 수정
Namgyeon b8f1f6e
배포 오류 수정을 위해 파일경로 수정
Namgyeon c9c3229
배포 오류 수정
Namgyeon 4e00daa
feat: 서버사이드 렌더링으로 변경
Namgyeon f4de0eb
feat: AllPosts SSR로 변경
Namgyeon 38b936a
feat: api요청에 URLSearchParams를 사용
Namgyeon 6f7bdb6
feat: OrderByValue type alias 추가
Namgyeon 979b2ac
feat: baseURL 상수화
Namgyeon a0c4627
feat: 에러 핸들링 수정
Namgyeon 75419fb
feat: 불필요한 상태 제거
Namgyeon 895e82a
refactor: 콤포넌트 prop 가독성, 유지보수 개선
Namgyeon a09eae4
refactor: 불필요한 useState삭제, textMapper 객체를 활용하여 기능 유지
Namgyeon bbaa9f2
refactor: useMediaQuery hooks를 따로 구분하여 가독성 개선
Namgyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { useState, useEffect } from "react"; | ||
| // 479, 767, 1023 | ||
|
|
||
| type MediaQuery = { | ||
| isMobile: boolean; | ||
| isTablet: boolean; | ||
| isDesktop: boolean; | ||
| }; | ||
|
|
||
| export function useMediaQuery(): MediaQuery { | ||
| const [pageSize, setPageSize] = useState({ | ||
| isMobile: false, | ||
| isTablet: false, | ||
| isDesktop: false, | ||
| }); | ||
|
|
||
| const updatePageSize = () => { | ||
| const width = window.innerWidth; | ||
|
|
||
| setPageSize({ | ||
| isMobile: width < 480, | ||
| isTablet: width >= 480 && width < 768, | ||
| isDesktop: width >= 768, | ||
| }); | ||
| }; | ||
| // 추후 디바운스 활용해서 최적화 도전(공부필요). | ||
| useEffect(() => { | ||
| updatePageSize(); | ||
|
|
||
| const handleResize = () => updatePageSize(); | ||
| window.addEventListener("resize", handleResize); | ||
|
|
||
| return () => { | ||
| window.removeEventListener("resize", handleResize); | ||
| }; | ||
| }, []); | ||
|
|
||
| return pageSize; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
오 커스텀 훅 사용하신거 상당히 좋습니다.
조금만 더 정리해본다면, 지금 상황의 경우,
pageSize가 객체로 데이터를 주다보니 결국 활용하는 입장에서 이 결과를 또 다시 어디ㅓㄴ가 풀어 사용해야할텐데요.그냥 이런 경우 직관적으로 풀어서 필드 하나씩 때려주는것도 괜찮은 방법이에요.
개인적으로 사용하는 코드 참고 차원에서 첨부드립니다