feat(lotto): useReview 훅 + useBriefing 4계층 정규화

This commit is contained in:
2026-05-11 08:57:14 +09:00
parent 9d2dfad512
commit cd3c538eb7
2 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
import { useEffect, useState } from 'react';
import { getLatestReview, getReviewHistory } from '../../../api';
export default function useReview() {
const [latest, setLatest] = useState(null);
const [history, setHistory] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
let cancel = false;
Promise.all([getLatestReview(), getReviewHistory(4)])
.then(([l, h]) => {
if (cancel) return;
setLatest(l);
setHistory(h);
})
.catch(() => {})
.finally(() => !cancel && setLoading(false));
return () => { cancel = true; };
}, []);
return { latest, history, loading };
}