[공통] dashboard-header, side-menu API 연동 및 데이터 페칭 custom hook 작업 #40
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.
#️⃣ Related Issue
📝 Problem
✅ Solving
📚 Attachment
useAsync, useFetch, useMutate
useAsync (ts 없는 버전)
useAsync는 data, loading, error 상태를 관리하는 훅입니다.
기존에는 useRef가 없는 조금 단순한 형태였는데, 이전에 멘토님의 조언을 반영함에 따라서 좀 복잡한 형태가 되었습니다.
이 훅을 직접 실행할 일은 없고, useFetch, useMutate를 호출하여 사용합니다.
useFetch
GET을 위한 훅입니다.
immediate (default = true)를 넣어 즉시 fetch를 실행하거나 실행하지 않을 수 있고,
deps를 넣어 refetch 조건을 만들 수 있습니다.
useMutate
PUT, POST, DELETE를 위한 훅입니다.
기본적으로 즉시 fetch가 되지 않으며, mutate를 호출하면 fetch가 됩니다.
다음과 같이 사용합니다!