useEffect(() => {
if (params.usersearch === props.search || "random" === props.search) {
console.log('same');
return;
}else{
console.log(props.search);
console.log('Params is :',params.usersearch);
let api = `https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=${apiKey}&tags=${params.usersearch}&per_page=24&format=json&nojsoncallback=1`;
props.handleLoading(true); //changing state
let fetchedData = axios
.get(api)
.then((data) => data.data.photos.photo)
.catch((err) => console.log(err));
props.handleData(fetchedData); //changing state
props.handleSearch(params.usersearch); //changing state
props.handleLoading(false); //changing state
const title = document.querySelector("title");
title.textContent = `Flickr-Photos/${params.usersearch}`;
}
},[params.usersearch]);
Hi everyone. I have a question , If my useEffect is running and it in between changes state(as I have mentioned when the props.handleLoading function gets triggered ), so is it gonna stop the and re-run the useEffect method or it is gonna complete the code?
useEffect
changes. Surely your testing would observe and confirm this?