Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactcustom hooksSingle-choice MCQ

A custom hook returns an object { data, refetch }. Consumers complain that refetch changes identity on every render, breaking their useEffect deps. What is the correct fix inside the hook?

function useData(url) { const [data, setData] = useState(null); const refetch = () => fetch(url).then(r => r.json()).then(setData); return { data, refetch }; }