-
Notifications
You must be signed in to change notification settings - Fork 26
[황휘태] sprint8 #123
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
The head ref may contain hidden characters: "React-\uD669\uD718\uD0DC-sprint8"
[황휘태] sprint8 #123
Changes from all commits
f00023f
63ea427
055407a
ec03870
49cf6d9
1d9ff17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,5 @@ dist-ssr | |
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| *.env | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,18 +3,18 @@ import { useEffect, useState } from "react"; | |
| /** | ||
| * 데이터 통신을 위한 공통 커스텀 훅 | ||
| * @param {Function} fetchFunction 서버와 직접 통신하는 함수 | ||
| * @returns {data: object, isLoading: boolean} | ||
| * @returns {data: object, isLoading: boolean, error: boolean} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 타입스크립트를 적용하게 되면 !이제 jsdoc으로 일일히 타입을 명시하지 않아도 되겠네요 😊😊😊 |
||
| */ | ||
| const useService = (fetchFunction) => { | ||
| const useFetch = (fetchFunction) => { | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [data, setData] = useState(); | ||
| const [error, setError] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const getService = async (getDataFunction) => { | ||
| const fetcher = async (fetching) => { | ||
| try { | ||
| setIsLoading(true); | ||
| const response = await getDataFunction(); | ||
| const response = await fetching(); | ||
|
|
||
| if (!response) { | ||
| throw new Error("서버와의 통신에 실패했습니다."); | ||
|
|
@@ -29,10 +29,10 @@ const useService = (fetchFunction) => { | |
| } | ||
| }; | ||
|
|
||
| getService(fetchFunction); | ||
| fetcher(fetchFunction); | ||
| }, []); | ||
|
|
||
| return { data, isLoading, error }; | ||
| }; | ||
|
|
||
| export default useService; | ||
| export default useFetch; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom/client"; | ||
| import App from "./App.tsx"; | ||
| import { BrowserRouter } from "react-router"; | ||
|
|
||
| ReactDOM.createRoot(document.getElementById("root")!).render( | ||
| <React.StrictMode> | ||
| <BrowserRouter> | ||
| <App /> | ||
| </BrowserRouter> | ||
| </React.StrictMode> | ||
| ); |
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.
굿굿 ! 함수의 이름이 더욱 명확해졌네요 👍
의미가 명확해져서 어떤 훅인지 더욱 정확히 알 수 있군요 😉