Skip to content

Commit

Permalink
feat : add hooks/useGetDailyItem.js (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
JungYeonHwi committed Oct 23, 2023
1 parent 7c76c2b commit f58a461
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions hooks/useGetDailyItem.js
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;

0 comments on commit f58a461

Please sign in to comment.