Reputation: 7822
This is the code in question:
useEffect(() => {
setStart(start + count);
const fetchImages = () => {
axios
.get(`/api/photos?count=${count}&start=${start}`)
.then((res) => setImages(images, ...res.data));
fetchImages();
};
}, []);
How can I use fetchImages
outside of the useEffect
hook?
Upvotes: 1
Views: 44
Reputation: 1353
You need to put fetchImages
outside of useEffect and wrap it with useCallback and then you can use fetchImages
outside of useEffect
and inside the useEffect
as well
Upvotes: 1