-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : add hooks/useGetDailyItem.js (#83)
- Loading branch information
1 parent
7c76c2b
commit f58a461
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useEffect, useState } from "react"; | ||
import predictionService from "services/prediction.service"; | ||
|
||
const useGetDailyItem = (id) => { | ||
const [data, setData] = useState(""); | ||
|
||
useEffect(() => { | ||
const getDailyItem = async() => { | ||
if (id !== undefined) { | ||
const fetchData = await predictionService.getDailyItem(id); | ||
setData(fetchData); | ||
} | ||
} | ||
|
||
getDailyItem(); | ||
}, [id]); | ||
|
||
return data; | ||
} | ||
|
||
export default useGetDailyItem; |