With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request
./src/components/Bu
This article is a good primer on fetching data with hooks: https://www.robinwieruch.de/react-hooks-fetch-data/
Essentially, include the fetch function definition inside useEffect
:
useEffect(() => {
const fetchBusinesses = () => {
return fetch("theUrl"...
// ...your fetch implementation
);
}
fetchBusinesses();
}, []);