-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: msw 오류를 해결하기 위한 msw 1.2.3 버전으로 업그레이드 * feat: (#123) 라우팅 경로 추가 * feat: (#123) 웹용 헤더 로고 누르면 메인 페이지로 이동 * test: (#123) 웹용 헤더 기능 추가에 따른 테스트 변경 * design: (#123) 데스크탑용 리스트 가로길이 변경(500px->700px) * refactor: (#123) 중복되는 기능 함수 합치기 * refactor: (#123) 레이아웃 컴포넌트와 동일 기능을 하는 스타일드 컴포넌트 삭제 * feat: (#123) 홈페이지를 제외한 페이지 컴포넌트에 레이아웃 컴포넌트 적용 * style: (#123) 불필요한 파일 삭제 * design: (#123) 헤더 상단 고정 * design: (#123) 검색바 svg 버튼색을 헤더색으로 설정 * design: (#123) 모바일버전 main 태그 상단margin 추가 * design: (#123) 선택지 margin 줄이기 * refactor: (#123) 레이아웃의 프롭스 정보를 컴포넌트 안에서 만들도록 수정 - 정보: 유저정보, 카테고리 목록, 카테고리 선호목록, 선호 카테고리 추가/삭제 이벤트 * test: (#123) 프롭스 수정에 따른 테스트 수정 * feat: (#123) 게시글 작성/수정 페이지에 레이아웃 컴포넌트 적용 * design: (#123) 글작성 폼 중앙정렬 * design: (#123) 게시글 내 정보(제목, 작성자 등)간 간격 넓히기 * refactor: (#123) 팀 코드 컨벤션에 맞게 클릭 함수명 수정 * test: (#123) 함수명/프롭스명 수정에 따른 테스트코드 변경 * design: (#123) 사이드바 Drawer 세로 일부 공백 제거 * refactor: (#123) 다른 pr과 충돌을 방지하기 위해 라우터 초기화
- Loading branch information
Showing
29 changed files
with
264 additions
and
618 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useCallback, useEffect, useState } from 'react'; | ||
|
||
export const useFetch = <T>(fetchFn: () => Promise<T>) => { | ||
const [data, setData] = useState<T>(); | ||
const [errorMessage, setErrorMessage] = useState<string>(); | ||
const [data, setData] = useState<T | null>(null); | ||
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
const refetch = useCallback(() => { | ||
setIsLoading(true); | ||
setData(null); | ||
setErrorMessage(null); | ||
|
||
fetchFn() | ||
.then(res => { | ||
setData(res); | ||
}) | ||
.catch(rej => { | ||
setErrorMessage(rej.message); | ||
.catch(error => { | ||
setErrorMessage(error.message); | ||
}) | ||
.finally(() => { | ||
setIsLoading(false); | ||
}); | ||
}, [fetchFn]); | ||
|
||
return (() => { | ||
setData(undefined); | ||
setIsLoading(true); | ||
setErrorMessage(undefined); | ||
})(); | ||
useEffect(() => { | ||
refetch(); | ||
}, []); | ||
|
||
return { data, errorMessage, isLoading }; | ||
return { data, errorMessage, isLoading, refetch }; | ||
}; |
Oops, something went wrong.